[Moztrap] REST API PUT will return error code 500 or 301

RESOLVED WONTFIX

Status

Mozilla QA
MozTrap
P1
major
RESOLVED WONTFIX
3 years ago
7 months ago

People

(Reporter: mlien, Unassigned)

Tracking

Details

(Reporter)

Description

3 years ago
Use REST API PUT to update case will get error code
500 INTERNAL SERVER ERROR (through python requests)
301 MOVED PERMANENTLY (through firefox add-ons: RESTClient)
(Reporter)

Updated

3 years ago
Severity: normal → major
Priority: -- → P1
(Reporter)

Comment 1

3 years ago
ni peter to give a comment on this issue

hi peter, do you happen to know why is REST API "PUT" cannot work normally?
I can use GET to query, but use PUT to update case will fail
Flags: needinfo?(peterbe)
Which endpoint?
Perhaps it was never configured to allow PUTs. Or more likely, there's a bug. If PUTs weren't allowed it shouldn't return a 500, it should return a 405. 

We should also rope in camd here because I think he added most of the TastyPie on to top of moztrap.
Flags: needinfo?(peterbe)
(Reporter)

Comment 3

3 years ago
Hi Cameron, as Peter said you are much familiar to TastyPie on to top of moztrap.
If you have any idea why REST API PUT return 301 or 500 on moztrap?
Flags: needinfo?(cdawson)
Hi Mike--  I think Peter is right.  It's a bug.  That endpoint SHOULD support PUT ok.  Are you able to run a local instance of it to test with?  It may be that it's choking on part of the data you're submitting.  It shouldn't return a 500, though, of course.  Should be a 4XX at worst.  Can you attach a sample of a case you're trying to submit?  Perhaps I can determine where the error is.

Updated

3 years ago
Flags: needinfo?(cdawson)
(Reporter)

Comment 5

3 years ago
I also test it on the local version and it's the same.
My sample is:
GET: https://moztrap.mozilla.org/api/v1/caseversion/123128?format=json

and remove one tag data, "{"description": "", "id": "2683", "name": "v1.0", "product": "/api/v1/product/16/", "resource_uri": "/api/v1/tag/2683/"}"

finally, PUT it back: https://moztrap.mozilla.org/api/v1/caseversion/123128?username=mlien&api_key=$my_api_key
(Reporter)

Comment 6

3 years ago
could I modify the tag item in caseversion's PUT?
Flags: needinfo?(cdawson)
Mike--  I can see in the code for CaseVersionResource that the tags field is set to read only:
https://github.com/mozilla/moztrap/blob/master/moztrap/model/library/api.py#L206-206

I agree this should have returned a 4XX of some kind, rather than a 500.

I think we could modify that so tags is NOT read only, but I recall when the dev that worked on this implemented it, she said tags were a little tricky.  I don't recall why it was tricky, however.  It's a many-to-many relationship.  I suppose part of the trick would be if the tag did not exist yet, you'd have to create it (or skip it).  But it still doesn't seem like it should be impossible.

In your case, it sounds like you're trying to remove a tag, right?
I think we'd need to update the tags field on ``CaseVersionResource`` and then update the ``obj_update`` function to handle tags.

FWIW: I actually get a 401 in the moztrap log when I try to do that PUT.
Flags: needinfo?(cdawson)
(Reporter)

Comment 9

3 years ago
Yes, my example just try to remove a tag.
But I also would like to add an exist tag to test case.

As my understanding, if test case inherits previous version, it will clone the same tags.
But if I add a new tag to specific version, it won't apply to other versions.
I'm not sure whether this is part of tricks or not.

Anyway, I think tag can be updated is a useful function.
Even we may add some limitation to it, but will better than read-only.

I never get a 401 in this case and now it returns 500 in RESTClient with below error message: 
{"error_message": "Sorry, this request could not be processed. Please try again later."}
(Reporter)

Comment 10

3 years ago
Digression:
I notice that not only tags but environments and steps are read-only.
Is that means I cannot update a case from PUT in mostly parts?
Mass-closing remaining MozTrap bugs as WONTFIX, due to 1) the Mozilla-hosted instance being decommissioned (see https://wiki.mozilla.org/TestEngineering/Testrail), and, for now, 2) the still-up code archived at its GitHub page: https://github.com/mozilla/moztrap (we'll decide what's next for that, in the near future).

See also the history and more-detailed discussion which led us here, at https://groups.google.com/forum/#!topic/mozilla.dev.quality/Sa75hV8Ywvk

(If you'd like, you should be able to filter these notification emails using at least the unique string of "Sa75hV8Ywvk" in the message body.

Thanks!
Status: NEW → RESOLVED
Last Resolved: 7 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.