Skip to content

Bug 2081819 - Remove the legacy REST server - #2842

Merged
dklawren merged 7 commits into
mozilla:masterfrom
Xzzz:bug-2081819
Nov 24, 2026
Merged

dklawren merged 7 commits into
mozilla:masterfrom
Xzzz:bug-2081819

Conversation

@Xzzz

@Xzzz Xzzz commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Removes the legacy REST server (rest.cgi, Bugzilla::WebService::Server::REST and the JSON-RPC code under it) and the Bugzilla::WebService base modules, now that every REST resource is served by a native Mojo controller.

Part of 2057358: since 2094122 moved the last extension resources to native controllers, nothing is left on the legacy server.

Changes

  • Any path under /rest or /rest.cgi without a native route returns the same rest_invalid_resource error as before (404, code 32614).
  • JSONP output (Accept: application/javascript with callback) is gone: it was only supported by the legacy server.
  • An error raised by a /rest route before its handler starts is now returned as a JSON API error instead of a 500.
  • Removed hooks: webservice, webservice_before_call, webservice_fix_credentials, webservice_rest_request, webservice_rest_resources, webservice_rest_response. webservice_error_codes now applies to native API errors.
  • wants_object and datetime_format_inbound move to Bugzilla::API::V1::Util; Bugzilla::WebService::Constants and Bugzilla::WebService::Wants stay.
  • The API docs no longer describe JSONP or the legacy authentication path.

Not carried over

  • The JSON::RPC and Test::Taint dependencies and the jsonrpc/rest features in Makefile.PL: templates still check feature_enabled('jsonrpc') for user autocompletion and comment tags, so they are left for a follow-up.

Test plan

  • GET /rest/no_such_resource and GET /rest.cgi/bug/1 return a JSON 404 with code 32614
  • GET /rest/bug/<id> still works, with and without an API key
  • Bug page: edit and save a bug, comment tags, user autocompletion

References

Xzzz added 6 commits November 24, 2026 19:53
Every REST resource is now served by a native Mojo controller, so rest.cgi and the JSON-RPC
based server behind it have nothing left to serve.

- Delete rest.cgi, Bugzilla::WebService::Server::REST and Bugzilla::WebService::Server::JSONRPC,
  the routes sending /rest, /rest/* and /rest.cgi/* to them, the preload, and their FEATURE_FILES
  entries
- Any other path under /rest or /rest.cgi now goes to a native route that returns the same
  rest_invalid_resource error (404, code 32614) rest.cgi returned
- Remove the JSON-RPC errors only that server threw
- t/app-cgi-request-limit.t: the oversized POST to /rest/version is answered by the new route,
  without the legacy x-bugzilla-login CORS header.
BMO.getBugsConfirmer, BMO.getBugsVerifier and Example.hello only served JSON-RPC which is gone.
Removed them, the webservice and webservice_rest_resources hook subs that registered them.
Nothing fires the webservice, webservice_before_call, webservice_rest_request, webservice_rest_resources,
and webservice_rest_response hooks any more: they were called by the legacy REST/JSON-RPC server.

- Removed WS_DISPATCH, which ran the webservice hook, and Bugzilla::WebService::Server::handle_login,
  which ran webservice_before_call
- Removed their documentation in Bugzilla::Hook and the Example extension's subs

webservice_error_codes and webservice_status_code_map stay, as native API errors, webservice_bug_get,
webservice_bug_render_comment and webservice_user_get still use them.
With the legacy server gone, the native API only used two helpers from these modules.

- Move wants_object and datetime_format_inbound into Bugzilla::API::V1::Util, for Bugzilla::API::V1::Bug.
- Delete Bugzilla::WebService, Bugzilla::WebService::Server, Bugzilla::WebService::Util (fix_credentials,
  taint_data) and the README, with t/webservice-fix-credentials.t and the webservice_fix_credentials hook.
  The native login keeps the header precedence, covered by qa/t/rest_native_login.t.
- Remove the JSON-RPC usage and error modes (USAGE_MODE_JSON, ERROR_MODE_JSON_RPC) and
  REST_CONTENT_TYPE_WHITELIST, which nothing uses any more.
…gone

- general.md: the API only returns JSON (JSONP was a legacy server feature), and the authentication
  section no longer refers to the legacy authentication path.
- The get_bug rate limit no longer covers JSON-RPC.
…rrors

Native /rest routes start in USAGE_MODE_REST and only switch to USAGE_MODE_MOJO_REST in their handler.
A ThrowUserError or ThrowCodeError before that still went to the legacy REST error path, which needs
the JSON-RPC server object that only rest.cgi created, so it ended in a 500 (Bugzilla::App::Plugin::Login
switched modes by hand to avoid it).

- Bugzilla::Error now switches such errors to USAGE_MODE_MOJO_REST, so the Mojo error plugin renders
  them as JSON like any native API error, and the legacy path and Bugzilla->_json_server are removed.
- The Mojo error plugin runs the webservice_error_codes hook, which only that legacy path ran,
  so extensions can still give their errors a code.
- New test in t/app-api-load.t.
@dklawren

Copy link
Copy Markdown
Collaborator

A comment at Bugzilla/App/Plugin/Login.pm:67 still mentions rest.cgi. That file isn't in this PR, but was flagged by review.

Possible fix: change that line to "(which is what produces account_disabled in the web UI)".

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.

🟢 Approval recommended

No active review issues block the removal of the legacy REST stack.

No open issues 🎉

What changed in this PR

Removes the legacy REST server now that all REST resources use native Mojo controllers, continuing the API migration tracked by bug 2057358.

Changes:

  • Deletes the legacy REST/JSON-RPC stack, extension dispatch code, and obsolete hooks.
  • Adds native unknown-resource handling and routes early REST errors through JSON error rendering.
  • Moves shared helpers into the native API utility module and updates tests and documentation.
File Description
template/​en/​default/​global/​user-error.html.tmpl Removes obsolete JSON-RPC error messages.
template/​en/​default/​admin/​params/​admin.html.tmpl Removes JSON-RPC from rate-limit help text.
t/​webservice-fix-credentials.t Deletes tests for removed credential handling.
t/​app-login-disabled-account.t Updates comments about error handling.
t/​app-cgi-request-limit.t Updates fallback expectations and removes a legacy header assertion.
t/​app-api-load.t Tests unknown resources and early REST errors.
rest.cgi Deletes the legacy REST entry point.
qa/​t/​rest_native_login.t Updates the credential-precedence comment.
extensions/​Example/​lib/​WebService.pm Deletes the legacy example service.
extensions/​Example/​Extension.pm Removes legacy service hooks.
extensions/​BMO/​lib/​WebService.pm Deletes the legacy BMO service.
extensions/​BMO/​Extension.pm Removes legacy service registration.
docs/​en/​md/​api/​core/​v1/​general.md Updates JSON format and authentication documentation.
Bugzilla/​WebService/​Util.pm Deletes legacy credential and taint helpers.
Bugzilla/​WebService/​Server/​REST.pm Deletes the legacy REST server.
Bugzilla/​WebService/​Server/​JSONRPC.pm Deletes the JSON-RPC server and JSONP support.
Bugzilla/​WebService/​Server.pm Deletes the legacy server base class.
Bugzilla/​WebService/​README Deletes obsolete architecture documentation.
Bugzilla/​WebService/​Constants.pm Removes legacy dispatch and protocol constants.
Bugzilla/​WebService.pm Deletes the legacy service base module.
Bugzilla/​Util.pm Removes JSON-RPC usage-mode detection.
Bugzilla/​Install/​Requirements.pm Removes deleted servers from feature-file mappings.
Bugzilla/​Hook.pm Removes documentation for obsolete hooks.
Bugzilla/​Error.pm Sends early REST errors through Mojo handling.
Bugzilla/​Constants.pm Removes JSON-RPC usage and error modes.
Bugzilla/​CGI.pm Removes the built-in rest.cgi path-info exception.
Bugzilla/​App/​Plugin/​Login.pm Updates comments for native-only error handling.
Bugzilla/​App/​Plugin/​Error.pm Applies extension error-code mappings to native errors.
Bugzilla/​App/​Controller/​CGI.pm Removes REST routing and CGI-specific REST handling.
Bugzilla/​App/​Controller/​API.pm Adds native unknown-resource fallback routes.
Bugzilla/​App.pm Removes legacy server loading and preloading.
Bugzilla/​API/​V1/​Util.pm Adds shared date-conversion and field-selection helpers.
Bugzilla/​API/​V1/​BugUserLastVisit.pm Updates the parameter-precedence comment.
Bugzilla/​API/​V1/​Bug.pm Uses helpers moved into native API utilities.
Bugzilla.pm Removes legacy server state and JSON-RPC mode handling.

Review effort: Balanced

@dklawren
dklawren merged commit 5c3dd20 into mozilla:master Nov 24, 2026
7 checks passed
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