Last modified: 2013-08-22 14:55:19 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T42032, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 40032 - Wikidata should not return 406 Not Acceptable
Wikidata should not return 406 Not Acceptable
Status: VERIFIED FIXED
Product: MediaWiki
Classification: Unclassified
ContentHandler (Other open bugs)
unspecified
All All
: Low normal (vote)
: 1.21.0 release
Assigned To: Wikidata bugs
: need-volunteer
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-06 00:14 UTC by This, that and the other (TTO)
Modified: 2013-08-22 14:55 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description This, that and the other (TTO) 2012-09-06 00:14:21 UTC
Attempting to use action=raw on a page using the Wikidata content model gives a HTTP 406 error:

http://wikidata-test-repo.wikimedia.de/w/index.php?title=Data:Q207&action=raw&ctype=text/css

This error is reserved for instances where the browser's "Accept" header does not list anything that the server can provide. [1] But modern browsers pass in "*/*" for this header, meaning all content types are acceptable, so error 406 should never be seen. 

Instead of serving 406, either the raw page content (as stored in the DB) should indeed be provided, or a more appropriate error should be provided.

[1] https://tools.ietf.org/html/rfc2616#section-10.4.7
Comment 1 Daniel Kinzler 2012-09-06 09:03:37 UTC
According to the spec, you are right. I can't really think of a good error code though.

I removed support for action=raw for non-text content as a response to an explicit request from the core team - I think it was Tim Starling. The reason is that the current expectation is that this will return wikitext, and returning JSON or XML or whatever would break that expectation. Also, while we can communicate the serialization format using the ContentType header, there is no way to tell the client which content *model* is used, which makes it impossible to interpret the returned data.

That, and the fact that action=raw is deprecated anyway.

So, what error code should be used? A plain 400? Btw, ctype=text/css is kind of like an accept header, and it's incompatible with the content model used in Q207, so... it kind of is a 406. Just that the format wasn't specified in the accept header.
Comment 2 Derk-Jan Hartman 2012-09-06 09:14:07 UTC
i'd say 404. what the url is requesting does not exist
Comment 3 Dereckson 2012-09-06 20:02:24 UTC
What about 501 Not Implemented?
Comment 4 Derk-Jan Hartman 2012-09-06 20:16:06 UTC
501 refers specifically to a HTTP method, but this is a simple GET and a GET is supported.
Comment 5 This, that and the other (TTO) 2012-09-07 00:52:00 UTC
Why does an HTTP error need to be served at all?  Couldn't there be a simple notice like we used to serve for empty pages be displayed?  e.g. 

/* This page uses a content model that is not supported by action=raw */
Comment 6 Daniel Kinzler 2012-09-07 07:42:00 UTC
(In reply to comment #5)
> Why does an HTTP error need to be served at all?  Couldn't there be a simple
> notice like we used to serve for empty pages be displayed?  e.g. 
> 
> /* This page uses a content model that is not supported by action=raw */

Because *programs* use this, and programs don't understand comments. They'd just take that as the actual page text, possibly using it as the basis for an edit etc.

We can serve such a comment, but it must be accompanied by a 4xx response code.
Comment 7 Daniel Kinzler 2012-09-07 07:50:03 UTC
A quick research shows these options:

418: "I'm a tea pot" (RFC 2324). It's defined thus:

   Any attempt to brew coffee with a teapot should result in the error
   code "418 I'm a teapot". The resulting entity body MAY be short and
   stout.

Thanks to Johl for that idea. I think however we might rather want to go with this:

415: "Unsupported Media Type" (RFC 2616). Sounds good:

   The server is refusing to service the request because the entity of
   the request is in a format not supported by the requested resource
   for the requested method.
Comment 8 Tim Starling 2012-10-14 23:36:28 UTC
Merged I6b7fbc5f.
Comment 9 denny vrandecic 2013-08-22 14:55:19 UTC
Closed older resolved bugs as verified.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links