Bug 2061445 - Migrate Bugzilla (system info) REST resource to native Mojo API - #2719
Bug 2061445 - Migrate Bugzilla (system info) REST resource to native Mojo API#2719Xzzz wants to merge 2 commits into
Conversation
| my ($self) = @_; | ||
|
|
||
| my $user = $self->bugzilla->login; | ||
| $user->id || return $self->user_error('login_required'); |
There was a problem hiding this comment.
usage_mode is still USAGE_MODE_REST here (set by _prepare_rest_request), so user_error hits neither branch in Bugzilla::App::Plugin::Error::_render_error and nothing gets rendered, an anonymous GET returns a 404 page instead of the JSON login_required error. every other native controller (Reminders, Teams, User) sets Bugzilla->usage_mode(USAGE_MODE_MOJO_REST) as the first statement, before login. same applies to any ThrowUserError raised inside login itself, eg a bad api key
suggest moving line 98 above line 95, and adding an anonymous-request case to qa/t/rest_bugzilla.t since the current test only covers the api-key path
| } | ||
| catch { | ||
| ERROR($_); | ||
| return $self->code_error('jobqueue_status_error'); |
There was a problem hiding this comment.
return inside a Try::Tiny catch block only returns from the block, not from jobqueue_status, so after code_error renders the 500 the sub falls through to the render below and overwrites the body with {"errors":0,"total":0} while the status stays 500. the old code died out of the catch via ThrowCodeError so it never reached that point
eg catch { ERROR($_) } then return $self->code_error('jobqueue_status_error') unless $status;
| my $dbh = Bugzilla->dbh; | ||
| my $db_time = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); | ||
| $db_time = datetime_from($db_time, 'UTC')->iso8601(); | ||
| my $now_utc = DateTime->now()->iso8601(); |
There was a problem hiding this comment.
response shape changes here: the legacy endpoint ran these through type('dateTime'), which is Bugzilla::WebService::Server::JSONRPC::datetime_format_outbound and appends a Z, so /rest/time used to return 2026-08-21T14:00:00Z. plain iso8601() drops the Z and clients that parse these as UTC will now read them as local time. suggest iso8601() . 'Z' for db_time, web_time and web_time_utc
|
|
||
| sub extensions { | ||
| my ($self) = @_; | ||
| Bugzilla->usage_mode(USAGE_MODE_MOJO_REST); |
There was a problem hiding this comment.
extensions and time were not in the old LOGIN_EXEMPT list, so the legacy server called Bugzilla->login() (LOGIN_NORMAL) for them, meaning they were gated when the requirelogin param is on. neither handler calls $self->bugzilla->login now, so both become anonymously readable under requirelogin. Teams.pm calls $self->bugzilla->login() for exactly this reason even though it does not use the user
Summary
Ports
Bugzilla::WebService::Bugzilla'sversion/extensions/timezone/time/jobqueue_statusmethods into a nativeBugzilla::API::V1::BugzillaMojo controller, mirroring the pattern already used for Classification/Component/Teams/Reminders/Configuration.This is a child bug of 2057358, see there for details.
Changes
Bugzilla/API/V1/Bugzilla.pm:GET /rest/version,/rest/extensions,/rest/timezone,/rest/time(public), and/rest/jobqueue_status(login required), same JSON response shape as the legacy endpointsBugzilla/WebService/Bugzilla.pmandBugzilla/WebService/Server/REST/Resources/Bugzilla.pmBugzillaentry fromWS_DISPATCHinBugzilla/WebService/Constants.pm, drop the correspondinguseline inBugzilla/WebService/Server/REST.pm, and remove the POD reference inBugzilla/WebService.pmqa/t/rest_user_login_logout.t: drop the assertions thatBugzilla_login/Bugzilla_passwordare honored/rejected on/rest/version. Native Mojo REST routes only support cookie,X-Bugzilla-API-Keyand OAuth2 bearer-token auth. Please note that this gap affects every resource already migrated to native Mojo, not just this one. Per discussion on 2057358 we're intentionally dropping username/password auth on native REST endpoints rather than porting it forward (cookie auth stays for web-UI JS, OAuth2 stays for Phabricator)Test plan
GET /rest/version,/rest/extensions,/rest/timezone,/rest/timereturn the expected JSON, matching the legacy endpoint outputGET /rest/jobqueue_statusrequires login (login_requiredwhen anonymous) and returns the expected counts when authenticated via API keyBugzilla_login/Bugzilla_passwordare now silently ignoredReferences