Skip to content

Bug 2061445 - Migrate Bugzilla (system info) REST resource to native Mojo API - #2719

Open
Xzzz wants to merge 2 commits into
mozilla:masterfrom
Xzzz:bug-2061445
Open

Bug 2061445 - Migrate Bugzilla (system info) REST resource to native Mojo API#2719
Xzzz wants to merge 2 commits into
mozilla:masterfrom
Xzzz:bug-2061445

Conversation

@Xzzz

@Xzzz Xzzz commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Ports Bugzilla::WebService::Bugzilla's version/extensions/timezone/time/jobqueue_status methods into a native Bugzilla::API::V1::Bugzilla Mojo controller, mirroring the pattern already used for Classification/Component/Teams/Reminders/Configuration.

This is a child bug of 2057358, see there for details.

Changes

  • Add 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 endpoints
  • Delete Bugzilla/WebService/Bugzilla.pm and Bugzilla/WebService/Server/REST/Resources/Bugzilla.pm
  • Remove the Bugzilla entry from WS_DISPATCH in Bugzilla/WebService/Constants.pm, drop the corresponding use line in Bugzilla/WebService/Server/REST.pm, and remove the POD reference in Bugzilla/WebService.pm
  • Update qa/t/rest_user_login_logout.t: drop the assertions that Bugzilla_login/Bugzilla_password are honored/rejected on /rest/version. Native Mojo REST routes only support cookie, X-Bugzilla-API-Key and 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

  • Verified against a local docker instance:
    • GET /rest/version, /rest/extensions, /rest/timezone, /rest/time return the expected JSON, matching the legacy endpoint output
    • GET /rest/jobqueue_status requires login (login_required when anonymous) and returns the expected counts when authenticated via API key
    • Confirmed cookie and API-key-based auth continue to work
    • Confirmed Bugzilla_login/Bugzilla_password are now silently ignored
  • Ran the sanity/bmo/webservices/selenium1-4 test suites clean

References

my ($self) = @_;

my $user = $self->bugzilla->login;
$user->id || return $self->user_error('login_required');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants