Skip to content

Bug 2094122 - Migrate extension WebService REST resources to native Mojo API - #2836

Open
Xzzz wants to merge 19 commits into
mozilla:masterfrom
Xzzz:bug-2094122
Open

Xzzz wants to merge 19 commits into
mozilla:masterfrom
Xzzz:bug-2094122

Conversation

@Xzzz

@Xzzz Xzzz commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Moves the REST endpoints that extensions still registered through the webservice hook from the legacy REST server to native Mojo controllers (extensions/<Name>/lib/API/V1/<Name>.pm), one commit per extension. Paths, parameters and responses stay the same, except for the changes listed below.

Last step of 2057358 before the legacy REST server can be removed in 2081819: no resource is left on it after this PR.

Changes

  • Migrated extensions, each one losing its lib/WebService.pm and webservice hook: InvalidBugHelper, Bitly, ProdCompSearch, EditComments, ComponentWatching, MyDashboard, PhabBugz (added to its existing controller), Review, BugModal.
  • mark_as_spam (InvalidBugHelper) and is_hidden (EditComments) must now be booleans (true/false/1/0).
  • EditComments: a comment_id sent with a PUT no longer replaces the one in the path.
  • ComponentWatching: the "product does not exist" error now names the product (also on the Preferences page).
  • MyDashboard: run_flag_query refuses a type other than requestee or requester, which it used to treat as requester.
  • qa/t/rest_legacy_credentials.t is removed, as no endpoint is left on the legacy server.
  • New or rewritten t/bmo tests in each extension call the routes.

Test plan

  • "Close as Invalid" on a bug as an editbugs user
  • "Short URL" on a buglist
  • Product/component search and most-used components on enter_bug.cgi
  • Edit a comment and hide a revision
  • Watch/Unwatch a component, and Preferences > Component Watching
  • My Dashboard: queries, requests, last changes, "remove from interesting"
  • Phabricator revisions on a bug, Phabricator link on a user profile
  • Suggested reviewers when requesting review, and the review history page
  • Bug page: edit mode, CC list, comment tags, product change; filing a new bug

References

Xzzz added 13 commits November 18, 2026 23:51
…jo API

POST /rest/invalid_bug_helper/close/<id> is now served by the native controller
Bugzilla::Extension::InvalidBugHelper::API::V1::InvalidBugHelper instead of the
legacy REST server. Same path, parameters, checks and response, mark_as_spam must
now be a boolean.

The legacy WebService module and its webservice hook are removed, and the extension
test now goes through the real route.
GET /rest/bitly/shorten and GET /rest/bitly/list are now served by the native controller
Bugzilla::Extension::Bitly::API::V1::Bitly instead of the legacy REST server.
Same paths, url parameter, checks and {url} response.

The legacy WebService module and its webservice hook are removed, and a test covers
both routes.
… API

GET /rest/prod_comp_search/find/<search> and GET /rest/prod_comp_search/frequent
are now served by the native controller Bugzilla::Extension::ProdCompSearch::API::V1::ProdCompSearch
instead of the legacy REST server. Same paths, limit parameter, queries and responses.

The legacy WebService module and its webservice hook are removed, and a test covers both routes.
GET /rest/editcomments/comment[/<id>], PUT /rest/editcomments/comment/<id> and
PUT /rest/editcomments/revision are now served by the native controller
Bugzilla::Extension::EditComments::API::V1::EditComments instead of the legacy REST server.
Same paths, parameters, checks and responses and is_hidden must now be a boolean (true/false/1/0).

The legacy WebService module and its webservice hook are removed, and a test covers the four routes.
…ojo API

GET and POST /rest/component-watching, GET and DELETE /rest/component-watching/<id> are now served
by the native controller Bugzilla::Extension::ComponentWatching::API::V1::ComponentWatching instead
of the legacy REST server. Same paths, parameters, checks and responses, except that product_access_denied
now names the product (it was passed as product instead of name, so the message showed '').
The Preferences page gets the same fix.

The legacy WebService module and its webservice hook are removed, and a test covers the four routes.
rest_legacy_credentials.t moves to GET /rest/bug_modal/initial_field_values, still on the legacy server.
GET /rest/mydashboard/run_bug_query, run_flag_query and run_last_changes, and PUT
/rest/mydashboard/bug_interest_unmark (also still served without the prefix) are now
served by the native controller Bugzilla::Extension::MyDashboard::API::V1::MyDashboard
instead of the legacy REST server. Same paths, parameters, checks and responses.
The two query methods still read from the shadow database.

The legacy WebService module and its webservice hook are removed, and a test covers
the five routes.
query_flags meant to accept only requestee and requester, but its check (ne || ne) was always true,
so any other type was treated as requester and returned under that key. It now throws param_invalid,
and Queries.pm imports Bugzilla::Error, which that error path never needed before.
GET /rest/phabbugz/check_bug/<bug_id>/<user_id>, GET /rest/phabbugz/check_enter_bug/<product>/<user_id>,
GET /rest/phabbugz/bug_revisions/<bug_id> and GET /rest/phabbugz/user/<user_id> are now served by the
existing native controller Bugzilla::Extension::PhabBugz::API::V1::PhabBugz instead of the legacy REST
server. Same paths, checks and responses. The three read-only ones still use the shadow database.

The legacy WebService module and its webservice hook are removed, and webservice.t now calls the routes.
GET /rest/review/suggestions (by bug ID, product, product/component or query params) and
GET /rest/review/flag_activity (by flag ID, type name, requestee, setter, type ID or query
params) are now served by the native controller Bugzilla::Extension::Review::API::V1::Review
instead of the legacy REST server. Same paths, parameters, checks and responses, include_fields
and exclude_fields included.

The legacy WebService module and its webservice hook are removed, and a test covers both methods.
GET /rest/bug_modal/initial_field_values, product_info, edit/<id>, cc/<id>, comment_tags/<id> and
new_product/<id>, and PUT /rest/bug_modal/update_comment_tags/<id> are now served by the native controller
Bugzilla::Extension::BugModal::API::V1::BugModal instead of the legacy REST server. Same paths, parameters,
checks and responses. A bug id sent as a hash is now refused, as on the core bug routes.

The legacy WebService module and its webservice hook are removed, and a test covers the seven routes.
rest_legacy_credentials.t is deleted: no resource is left on the legacy REST server.
On a GET, the legacy REST server kept the id from the path even when the query string had one,
and only a PUT body or query string replaced it. The controller let a query-string id win on
GET too, so GET /rest/bug_modal/edit/5?id=6 answered for bug 6. The path id wins again on GET,
which also makes the hash id check unneeded, so it is removed.
…required

The legacy route matched /prod_comp_search/find/ with an empty search and returned the
param_required error. The *search placeholder needed at least one character, so it was a 404.
The placeholder now defaults to ''.
The legacy route matched /review/flag_activity/requestee/ (and setter/, type_id/) with an empty value,
which was then ignored. The *value placeholder made it a 404. The placeholder now defaults to ''.
Comment thread extensions/PhabBugz/t/bmo/webservice.t Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Authorization checks against a lagging shadow database can continue granting access after permissions are revoked and expose revision and reviewer metadata.

5 open issues
What changed in this PR

Migrates nine extensions’ remaining legacy REST resources to native Mojo controllers, completing the endpoint migration needed before the legacy REST server can be removed.

Changes:

  • Replaces legacy WebService registrations with native routes and JSON responses.
  • Tightens selected parameter validation and corrects ComponentWatching product errors.
  • Adds or rewrites route-level tests and removes the legacy credential test.
File Description
qa/​t/​rest_legacy_credentials.t Removes legacy password-authentication tests.
extensions/​Review/​t/​bmo/​review-api.t Tests reviewer suggestions and flag-history routes.
extensions/​Review/​lib/​WebService.pm Removes the legacy Review service.
extensions/​Review/​lib/​API/​V1/​Review.pm Adds native suggestions and flag-history routes.
extensions/​Review/​Extension.pm Removes legacy service registration.
extensions/​ProdCompSearch/​t/​bmo/​prod-comp-search.t Tests search and frequent-component routes.
extensions/​ProdCompSearch/​lib/​API/​V1/​ProdCompSearch.pm Migrates product/component searches to Mojo.
extensions/​ProdCompSearch/​Extension.pm Removes legacy service registration.
extensions/​PhabBugz/​t/​bmo/​webservice.t Exercises migrated routes with simulated Phabricator responses.
extensions/​PhabBugz/​lib/​WebService.pm Removes the legacy PhabBugz service.
extensions/​PhabBugz/​lib/​API/​V1/​PhabBugz.pm Adds permission, revision, and account routes.
extensions/​PhabBugz/​Extension.pm Removes legacy service registration.
extensions/​MyDashboard/​t/​bmo/​mydashboard-api.t Tests dashboard queries, visibility, and interest removal.
extensions/​MyDashboard/​lib/​Queries.pm Rejects unsupported flag-query types.
extensions/​MyDashboard/​lib/​API/​V1/​MyDashboard.pm Migrates dashboard routes and preserves the unprefixed alias.
extensions/​MyDashboard/​Extension.pm Removes legacy service registration.
extensions/​InvalidBugHelper/​t/​bmo/​invalid-bug-helper.t Converts invalid-bug checks to route-level tests.
extensions/​InvalidBugHelper/​lib/​API/​V1/​InvalidBugHelper.pm Migrates bug closing and adds boolean coercion.
extensions/​InvalidBugHelper/​Extension.pm Removes legacy service registration.
extensions/​EditComments/​t/​bmo/​editcomments-api.t Tests comment editing, visibility, and revision routes.
extensions/​EditComments/​lib/​WebService.pm Removes the legacy comment-editing service.
extensions/​EditComments/​lib/​API/​V1/​EditComments.pm Adds native routes, path-ID precedence, and boolean coercion.
extensions/​EditComments/​Extension.pm Removes legacy service registration.
extensions/​ComponentWatching/​t/​bmo/​component-watching-api.t Tests watch creation, retrieval, ownership, and deletion.
extensions/​ComponentWatching/​lib/​WebService.pm Removes the legacy component-watching service.
extensions/​ComponentWatching/​lib/​API/​V1/​ComponentWatching.pm Adds native watch-management routes.
extensions/​ComponentWatching/​Extension.pm Fixes product error arguments and removes registration.
extensions/​BugModal/​t/​bmo/​bug-modal-api.t Tests bug-page routes and access checks.
extensions/​BugModal/​lib/​API/​V1/​BugModal.pm Migrates bug-page data and comment-tag routes.
extensions/​BugModal/​Extension.pm Removes legacy service registration.
extensions/​Bitly/​t/​bmo/​bitly.t Tests URL routes with a simulated Bitly service.
extensions/​Bitly/​lib/​API/​V1/​Bitly.pm Migrates URL-shortening routes to Mojo.
extensions/​Bitly/​Extension.pm Removes legacy service registration.

Review effort: Balanced

my ($self) = @_;
Bugzilla->usage_mode(USAGE_MODE_MOJO_REST);
my $user = $self->_login || return;
Bugzilla->switch_to_shadow_db();

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.

Could probably just remove Bugzilla->switch_to_shadow_db() completely and accomplish the same thing.

my ($self) = @_;
Bugzilla->usage_mode(USAGE_MODE_MOJO_REST);
my $user = $self->_login || return;
Bugzilla->switch_to_shadow_db();
$self->_check_phabricator();

my $user = $self->_login || return;
Bugzilla->switch_to_shadow_db();
Comment on lines +23 to +26
$r->get('/component-watching')->to($to . 'list');
$r->post('/component-watching')->to($to . 'add');
$r->get('/component-watching/:id' => [id => qr/\d+/])->to($to . 'get');
$r->delete('/component-watching/:id' => [id => qr/\d+/])->to($to . 'remove');

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.

Let's make sure we add OPTIONS for any migrated code that needs it.

Comment on lines +104 to +106
if ($error = coerce_booleans($params, 'is_hidden')) {
return $self->user_error('invalid_params', {type_error => $error});
}

@dklawren dklawren left a comment

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.

LGTM. r=dkl

This branch has not been deployed

No deployments
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.

3 participants