Repository navigation
Conversation
…ts (get, search, create, update, possible_duplicates, history)
| Bugzilla::Hook::process('webservice_bug_get', | ||
| {webservice => $self, user => $user, params => $params, bug_data => \@hashes,}); | ||
|
|
||
| return $self->render(json => {bugs => \@hashes, faults => \@faults}); |
There was a problem hiding this comment.
ETag support looks like it was lost here. The legacy get() called $self->bz_etag(\@hashes) before adding update tokens, and the REST/JSON-RPC server then sent the ETag header and answered If-None-Match with a 304. None of the native get/search/history handlers set an ETag.
Clients polling GET /rest/bug/123 with If-None-Match (bots, dashboards) will now get a full 200 body every time. Was dropping this intentional?
There was a problem hiding this comment.
Yes that was intentional. None of the native V1 modules send an ETag (Group, User, BugComment, BugAttachment...), so I kept Bug consistent with them, and the PR description lists it under "Not carried over".
=> If you'd rather keep ETag/304 for bug get/search/history, it's a small change and I can add it back in this PR.
There was a problem hiding this comment.
Yes. Let's add it back to bug get/search/history if we can. It might confuse clients who are using etag checks before getting the full bug/search. Sorry to change.
There was a problem hiding this comment.
No problem :)
Done in 68890f3: get, search and history send an ETag again and answer 304 Not Modified when If-None-Match matches. As in the legacy server, the ETag is the MD5 of the response data, and for get it's computed before the update tokens are added, since those change on every request.
Also, new checks in qa/t/rest_bug_routes.t for the three routes (fail without the fix). The ETag values differ from the legacy ones, so a client gets one full response after the deploy, then 304s again.
And, last but not least, PR description is updated too.
…and the Error plugin
dklawren
left a comment
There was a problem hiding this comment.
We can land this after etag support added back,
dklawren
left a comment
There was a problem hiding this comment.
Sorry. Found one more last issue. Then we should be good :)
|
Added some fixup after deeper review:
|
dklawren
left a comment
There was a problem hiding this comment.
Approved once the params issue is fixed.
| my $user = $self->bugzilla->login; | ||
| $user->id || return $self->user_error('login_required'); | ||
|
|
||
| my ($params, $responded) = $self->_request_params; |
There was a problem hiding this comment.
with no list params, a form-encoded create like cc=a&cc=b or groups=x&groups=y now keeps only the last value (legacy got an array), so ccs and groups get dropped silently. maybe pass the list fields here (cc, groups, keywords, blocks, depends_on, see_also...) or keep repeated keys as arrays like the GET branch does
Summary
Ports the remaining bug methods (
get,search,history,possible_duplicates,create,update) fromBugzilla::WebService::Buginto a nativeBugzilla::API::V1::BugMojo controller, and removes the legacy Bug module.Last of the four sub-bugs of 2081819.
Changes
Bugzilla/API/V1/Bug.pm, with the same responses as the legacy endpoints:GET/POST /rest/bug(search / create),GET /rest/bug/withidsin the query string (get)GET/PUT /rest/bug/<id>,GET /rest/bug/<id>/history,GET /rest/bug/possible_duplicatesOPTIONSon eachBugzilla/API/V1/Util.pm, used byBugAttachment,BugCommentandBuginstead of their own copies.Bugzilla/WebService/Bug.pm(includingupdate_see_also, which had no route),Resources/Bug.pmand theBugentry ofWS_DISPATCH.run_last_changesreads the bug activity directly.new_since,last_change_time,creation_time, datetime custom fields).getis rate-limited, logged-ingetis logged and audited, and thewebservice_bug_gethook runs.Bugzilla->input_paramsholds the request params, which extensions read in bug hooks (e.g. Needinfo'sneedinfo_from).createreturns 200: the legacy route asked for 201 but the server used 200.permissiveandfaultsfor Get Bug;general.mdlists onlyBugzillaas not migrated.qa/t/rest_bug_routes.t;t/app-cgi-request-limit.tchecks the legacyrest.cgipath with/rest/version.Behaviour changes:
api_key,login/password…) are not accepted, as on the other native resources: use theX-Bugzilla-API-Keyheader.permissiveongetnow works: a bug that can't be returned is listed infaults(id,faultString,faultCode). The legacy REST server failed the whole request.buglist_parameters_required(whensearch_allow_no_criteriais off) however the caller authenticates.Not carried over: JSONP
callback=, as in the other migrated V1 modules. Get, search and history keep their ETag and answer 304 to a matchingIf-None-Match.Test plan
GET /rest/bug/<id>andGET /rest/bug/?ids=<id>&ids=<alias>, logged out and logged in, withinclude_fields=_allGET /rest/bug/<id>?ids=<unknown>&permissive=1, expecting the bug plus a faultGET /rest/bug?product=<product>&limit=2,?quicksearch=ALL&limit=1,?count_only=1GET /rest/bug/<id>/history?new_since=<date>If-None-Match: <ETag>, expecting 304GET /rest/bug/possible_duplicates?summary=<words>&product=<product>POST /rest/bug, thenPUT /rest/bug/<id>with a comment and a flagReferences