Closed Bug 1093600 Opened 11 years ago Closed 11 years ago

REST shouldn't support multiple instances of parameters for resources which only support a single params (eg. POST bug/comment)

Categories

(Bugzilla :: WebService, defect)

4.5.6
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Bugzilla 5.0

People

(Reporter: pmoore, Assigned: dkl)

References

Details

Attachments

(2 files, 1 obsolete file)

curl -d 'id=1091084' --data-urlencode 'comment=In production: https://hg.mozilla.org/build/mozharness/rev/6375288c157b' --data-urlencode 'login=slaveapi@mozilla.releng.tld' --data-urlencode 'password=XXXXXXXXX' 'https://bugzilla.mozilla.org/rest/bug/1091084/comment' returned {"documentation":"http://www.bugzilla.org/docs/tip/en/html/api/","error":true,"code":100500,"message":"Not a HASH reference at /data/www/bugzilla.mozilla.org/Bugzilla/Bug.pm line 389.\n"} Normally this would post the comment "In production: https://hg.mozilla.org/build/mozharness/rev/6375288c157b" in bug 1091084 as user slaveapi@mozilla.releng.tld.
See Also: → 1004617
Request headers sent: 0000: POST /rest/bug/1091084/comment HTTP/1.1 0029: User-Agent: curl/7.30.0 0042: Host: bugzilla.mozilla.org 005e: Accept: */* 006b: Content-Length: 169 0080: Content-Type: application/x-www-form-urlencoded 00b1: Request body sent: 0000: id=1091084&comment=In%20production%3A%20https%3A%2F%2Fhg.mozilla 0040: .org%2Fbuild%2Fmozharness%2Frev%2F6375288c157b&login=slaveapi%40 0080: mozilla.releng.tld&password=XXXXXXXXXXXXX (password obfuscated)
looks like bug 1088253 caused this. my $id = ref($param) ? ($param->{id} = trim($param->{id})) : ($param = trim($param)); $params is now an arrayref: $params = [ '39', '39' ];
Severity: normal → critical
Depends on: 1088253
Assignee: nobody → glob
the bug id is being passed in twice - as part of the rest url and in the post data. with bug 1088253, this becomes an array with both of the id's, which Bugzilla::Bug doesn't understand. i think the safest thing to do right now is to backout bug 1088253, then work on a fix.
To ssh://gitolite3@git.mozilla.org/webtools/bmo/bugzilla.git 6ba0783..64fc523 master -> master
Many thanks glob!
This patch just removed the bug id from the post parameters.
Attachment #8516709 - Flags: review?(glob)
Comment on attachment 8516709 [details] [diff] [review] bug1093600_tools_v1.patch Review of attachment 8516709 [details] [diff] [review]: ----------------------------------------------------------------- r=glob this looks sane. i can't test the python, but i can confirm that a the bug id isn't required in the post body if it's present as part of the url.
Attachment #8516709 - Flags: review?(glob) → review+
Component: API → WebService
Product: bugzilla.mozilla.org → Bugzilla
QA Contact: default-qa
Summary: Bugzilla API call to add a comment now failing → Bugzilla API call to add a comment now failing due to commit by bug 1088253
Target Milestone: --- → Bugzilla 5.0
Version: Production → 4.5.6
I think we will update the code in REST.pm that combines the params to follow this flow: if (rest resource accepts a single value only) honour the query string only (old behavior) else merge params (as per current trunk/5.0 code) We can determine if the method accepts multiple params or not by looking at the bz_rest_params data that is returned by the REST/Resource/*.pm resource files. dkl
Assignee: glob → dkl
Status: NEW → ASSIGNED
Attached patch 1093600_1.patch (obsolete) — Splinter Review
Attachment #8518541 - Flags: review?(glob)
Summary: Bugzilla API call to add a comment now failing due to commit by bug 1088253 → REST shouldn't support multiple instances of parameters for resources which only support a single params (eg. POST bug/comment)
Comment on attachment 8518541 [details] [diff] [review] 1093600_1.patch >+ use Data::Dumper; print STDERR Dumper $params; > >+ print STDERR Dumper $params; Hrm....
Attached patch 1093600_2.patchSplinter Review
Oops. How did those get in there? :)
Attachment #8518541 - Attachment is obsolete: true
Attachment #8518541 - Flags: review?(glob)
Attachment #8518916 - Flags: review?(glob)
Comment on attachment 8518916 [details] [diff] [review] 1093600_2.patch Review of attachment 8518916 [details] [diff] [review]: ----------------------------------------------------------------- r=glob ::: Bugzilla/WebService/Server/REST.pm @@ +366,3 @@ > if ($self->request->method ne 'GET') { > my $extra_params = {}; > + # We do this manually cause CGI.pm doesn't understand JSON strings. nit: indented too much by one space, and s/cause/because/
Attachment #8518916 - Flags: review?(glob) → review+
Flags: approval5.0+
Flags: approval+
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git b9543e4..8d368ae master -> master
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
And 5.0: To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git 4e5a3b1..4a43627 5.0 -> 5.0
Blocks: 1096565
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: