Closed Bug 555251 Opened 12 years ago Closed 12 years ago

[k] format=json searches that don't actually search should return empty result set

Categories

(support.mozilla.org :: Search, defect, P4)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: jsocol, Assigned: paulc)

Details

Probably. Executing a search via JSON and finding a blob of HTML is probably confusing. We should at least send a 'no-results' style object, or possibly an error notification (if there is an error) and consider what response code we use. (404? How would that interact with Zeus?)
Priority: -- → P4
+1 for 404, that makes it easy to check in e.g. jQuery, e.g.
function error(XMLHttpResponse) {
    if (XMLHttpResponse).status == 404) {
        // show XMLHttpResponse.message
    }
}

Perhaps Shyam can tell us if that's a good idea?
Paul/James, a little more context? :) I don't completely understand what we're trying to do?
Shyam, my only question is if Zeus has any strange rules about caching 404s?
Unsure, Jeremy?
I believe zeus does cache 404s by default, but we can tell it not to cache them.
Assignee: nobody → paulc
Thanks Jeremy.

Pushed to development branch:
http://github.com/pcraciunoiu/kitsune/commit/6452eadb503a44d6e2679581b359b1f71aed82ed
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
For QA, basically:
* adding format=json in the URL should return JSON results.
* if no (valid!) callback is provided, Content-Type=application/json
* otherwise (no callback), Content-Type=application/x-javascript
It's easy to notice the Content-Type in Firefox, as it tries to download JSON but simply displays JavaScript.

Let me know if you have any other questions.
Here's what I tested, for comment 0:

* http://support-stage-new.mozilla.com/en-US/search?q=&format=json&callback=arr[1] yields {"error": "Invalid search data."}, served as application/x-javascript
* http://support-stage-new.mozilla.com/en-US/search?q=jksljfksljflsd&format=json&callback=arr[1] yields arr[1]({"query": "jksljfksljflsd", "message": "No pages matched the search criteria", "total": 0, "results": []}); also served as application/x-javascript
* http://support-stage-new.mozilla.com/en-US/search?q=sjkfljslf8ssf8d908sfd890s890af890sd&format=json yields the JS file as application/json

Verified?
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.