Add firefox xml parsing error
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Kaan Barmore-Genç 2022-12-17 21:38:45 -05:00
parent 4629683b98
commit 094d9faad8
Signed by: kaan
GPG Key ID: B2E280771CD62FCF
2 changed files with 47 additions and 0 deletions

content/img/2022-12-17.firefox.xml-parsing-error.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,44 @@
title: 'Solving "XML Parsing Error: no root element found" in Firefox'
date: 2022-12-17T21:27:37-05:00
toc: false
- dev
- web
I've been seeing this error a lot while working on my project [Bulgur Cloud](/bulgur-cloud-intro/).
It seems to show up only on Firefox:
![Error message in Firefox console. "XML Parsing Error: no root element found. Location: http://...701.jpg Line Number 1, Column 1](/img/2022-12-17.firefox.xml-parsing-error.png)
What is curious was that I was not actually loading the file mentioned in the
error message. I tried looking up what the error might mean, but all that came
up was very specific issues regarding some web frameworks, unrelated to what I'm
I later realized however, while I wasn't loading the file in the error message,
I was actually sending a `DELETE` request. The Bulgur Cloud server then responds
to this request with an empty `200 OK` response. Turns out, if you send an empty
response to Firefox, it tries to parse the body of the response even though it's
empty and gives you this error.
To quiet this error, I started just sending an empty JSON response even for
requests that don't actually need it. Here's some rust code to illustrate the
#[derive(Debug, Serialize)]
pub struct EmptySuccess {
status: &'static str,
// Using actix-web
fn empty_ok_response() -> HttpResponse {
HttpResponse::Ok().json(EmptySuccess { status: "ok"})
This adds a `{"status": "ok"}` json to the response, which seems to be enough to
make Firefox happy.