Fri 30 August 2013

The 406 error conundrum!

Posted by ankur in Tech (237 words, approximately a 1 minute read)

Some of you may have noticed that my blog wasn't coming up on the planet recently. No? *sigh*. Well, Ralph(threebean) finally dug out the "bug" earlier today. The first clue was the error from the planet that Kevin was nice enough to get for us:

ERROR:planet.runner:Error 406 while updating feed

Unfortunately, the 406 error description doesn't tell us much. What it did tell us though was that there's some incoherence in the header that our planet instance sends and the reply it receives. We kept trying other clients (curl/wget) and the default python http request and could not replicate it. After a lot of digging, Ralph ended up looking at bare httplib2 code since planet uses httplib2 to make it's requests. When he tried to get the blog feed off httplib2, he ran into this:

`` >>> import httplib2 >>> h = httplib2.Http() >>> response, content = h.request("") >>> response.status 406 >>> response, content = h.request("", headers={'user-agent': 'trololololololol 9000'}) >>> response.status 200``

It appears that mod_security, or waf (web app firewalls) tend to deny access to a list of agents as athmane explained later in #fedora-noc. The current work around is to just change the agent that the planet instance uses, which Ralph already did.

It wasn't really a major bug, but it was sure a tricky one to triage. If your blog wasn't turning up on the planet because of a 406 error, this should've hopefully fixed it. Cheers!