Closed Bug 963129 Opened 12 years ago Closed 12 years ago

Error trying to update an app via the API with categories

Categories

(Marketplace Graveyard :: API, defect, P2)

x86
macOS
defect

Tracking

(Not tracked)

VERIFIED FIXED
2014-02-18

People

(Reporter: bsilverberg, Assigned: mat)

Details

(Whiteboard: [fromAutomation][qa+])

I have created an app via the API and am now trying to update it via a PUT. When I pass in the category data as [155, 156] I get a 400 error back: {"categories":["Object with slug=155 does not exist."]} I tried passing in a list of slugs instead, i.e., ['games','books'] But that resulted in a 500 error with no useful message (other than {"detail":"Internal Server Error"}). Note that the list of categories I am using to choose values from is one that I am getting back from the categories api. This is on marketplace-dev.
Assignee: nobody → mpillard
Priority: -- → P2
I can't reproduce locally, can you: - Give more detailed info - which app were you updating, what's the API requests you were making and with what data. - Try to reproduce on -dev - I can't find the traceback, hopefully if you manage to reproduce it again it'll be easier for me to find it. Thanks.
Flags: needinfo?(bob.silverberg)
Mat, my apologies again for taking so long to get back to you on this. So many other priorities, but this is one I really need to address, so I'm going to make an effort to work with you on it. I ran the steps again and had the same results. I added a bit of debug info to the routine and have documented it in a gist. Here [1] you'll see each request that was made, along with the header and data that was sent, as well as the http response from the server. For the final request, which returns a 400 response, the content of the response is: {"categories":["Object with slug=155 does not exist."]} I tried passing in other data, including 'slug' (which generated a 500 error), 'resource_uri' (which generated a similar 400 response) and 'name' (which also generated a 500 error). Let me know if you need any more information from me or if there is anything else I can do to help debug this. [1] https://gist.github.com/bobsilverberg/8961966
Flags: needinfo?(bob.silverberg) → needinfo?(mpillard)
Ok thanks, I don't know what's up with the 400s yet, but at least I finally have some tracebacks to work on for the 500s: http://sentry.dmz.phx1.mozilla.com/addons/marketplace-dev/group/17999/ http://sentry.dmz.phx1.mozilla.com/addons/marketplace-dev/group/17986/
Flags: needinfo?(mpillard)
Interesting. That first 500 seems to suggest that the code is looking up the category by 'slug' as opposed to 'id', which is not what the code that was originally written (and working) did. I wonder why it's finding 3 records for that slug? Mat, are you continuing to investigate this? Do you need anything else from me?
We switched to slugs a while ago, that's the way to go. The problem is, it's finding multiple records because we are not filtering properly, we should only look at webapp categories (the database is shared with AMO, so we need to filter out extensions/themes categories) I'm fixing this right now, and then I'll double-check the remaining issues. I'll NEEDINFO you if I need more info, thanks.
Thanks Mat. Are there docs anywhere for the API that would have made clear the fact that I need to pass slugs and not ids?
The docs say "categories (array) – An array of strings representing the slugs of the categories the app belongs to.". It has been for quite a while. http://firefox-marketplace-api.readthedocs.org/en/latest/topics/apps.html#app-response-label It might not be obvious that it applies to requests *and* responses ? I'm not a good judge of that, since I wrote a good chunk of it and I'm very familiar with the API. If you have some suggestions as to what we could add and where, or better wording etc, file a bug and we'll do it. This PR should fix your first 500: https://github.com/mozilla/zamboni/pull/1759/ - the 400s were legitimate, since that happened when you were passing ids and not slugs. The second 500 was fixed in another bug.
Status: NEW → ASSIGNED
Target Milestone: --- → 2014-02-18
Thanks Mat. I wasn't suggesting that the docs were unclear. I just wasn't sure where to find the docs. Can you please update the bug after that change lands so I can do some more testing?
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
qa-, :bsilverberg will verify.
Whiteboard: [fromAutomation] → [fromAutomation][qa-]
Verified fixed on dev. Thanks mat.
Status: RESOLVED → VERIFIED
Whiteboard: [fromAutomation][qa-] → [fromAutomation][qa+]
You need to log in before you can comment on or make changes to this bug.