Skip to content

Bug 2086125 - [HACKBOT] Run status surfaced on the bug - #2829

Merged
dklawren merged 10 commits into
mozilla:masterfrom
dklawren:2086125
Dec 3, 2026
Merged

dklawren merged 10 commits into
mozilla:masterfrom
dklawren:2086125

Conversation

@dklawren

@dklawren dklawren commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a Hackbot module to the bug page that lists the bug's Hackbot runs: agent, status, origin, start time, and a "view run" link into the Hackbot UI. Until now a run gave no sign on the bug until it posted a comment, so nobody could tell whether Hackbot had picked up a needinfo request or was still working on it.

Screenshot

hackbot-runs-crop

Changes

  • New Hackbot extension. The bug page loads the table from GET /rest/hackbot/bug_runs/:bug_id, and BMO forwards that request to the Hackbot API (GET /bugs/N/runs, Bug 2091030 - Add the ability to filter runs based on bug id in the hackbot API ai-dev#7440) with an X-API-Key.
  • All runs for the bug are shown, whatever started them. Hackbot has no origin field, so BMO works it out from the run: needinfo, @hackbot on D123 (Phabricator), Hackbot UI, CI failure, or a follow-up run. Anything else shows as "Hackbot". The requester's BMO nick is added when Hackbot reports one.
  • Hidden when a bug has no runs, and when Hackbot is unreachable. Failures are logged on the server.
  • Access: editbugs only, and the user must be able to see the bug. Each run's bug_id must match the bug, so an API that ignores the filter can't leak runs from other bugs. Only nicks reach the browser, never emails or dedupe keys.
  • Caching: per-bug memcached entry, fresh for 30 s, then revalidated with the ETag via If-None-Match (kept for a day). Failures are cached for 60 s.
  • Parsing: responses are decoded as UTF-8 exactly once (Copilot's suggestion), and responses without an ETag are handled.
  • Config: new "Hackbot" params panel with hackbot_runs_enabled, hackbot_api_url, hackbot_api_key and hackbot_ui_url. Test data turns the feature on.

Tests

  • extensions/Hackbot/t/bmo/bug-runs.t: client (UTF-8, no ETag, failures), trimming, every origin, ETag/304/error caching.
  • qa/t/rest_hackbot_runs.t: login, editbugs and private-bug access, response shape.

Depends on

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

The client passes charset-decoded characters to a JSON decoder expecting UTF-8 bytes, causing valid non-ASCII responses to fail parsing, caching the failure, and hiding the runs module.

1 open issue
What changed in this PR

Adds a Hackbot integration to BMO that displays run status on bug pages for authorized editbugs members.

Changes:

  • Adds a permission-checked REST endpoint backed by a cached Hackbot API client.
  • Adds an asynchronously loaded run table with status, origin, start time, and run links.
  • Adds configuration switches, development defaults, and backend and REST tests.
File Description
scripts/​generate_bmo_data.pl Enables Hackbot features in generated development data.
qa/​t/​rest_hackbot_runs.t Tests REST access controls and run responses.
extensions/​Hackbot/​web/​style/​hackbot_runs.css Styles the run table and status badges.
extensions/​Hackbot/​web/​js/​hackbot_runs.js Fetches and renders runs on bug pages.
extensions/​Hackbot/​template/​en/​default/​hook/​bug_modal/​header-end.html.tmpl Loads Hackbot styles and JavaScript conditionally.
extensions/​Hackbot/​template/​en/​default/​hook/​bug_modal/​edit-module.html.tmpl Adds the initially hidden Hackbot module.
extensions/​Hackbot/​template/​en/​default/​hackbot/​table.html.tmpl Defines the run table structure.
extensions/​Hackbot/​template/​en/​default/​admin/​params/​hackbot.html.tmpl Documents integration settings for administrators.
extensions/​Hackbot/​t/​bmo/​bug-runs.t Tests API handling, filtering, requester mapping, and caching.
extensions/​Hackbot/​lib/​Constants.pm Defines access, timeout, cache, and validation constants.
extensions/​Hackbot/​lib/​Config.pm Defines feature switches and connection settings.
extensions/​Hackbot/​lib/​Client.pm Implements Hackbot API requests and conditional fetching.
extensions/​Hackbot/​lib/​BugRuns.pm Caches, filters, and prepares runs for display.
extensions/​Hackbot/​lib/​API/​V1/​Runs.pm Exposes runs with authentication and bug-visibility checks.
extensions/​Hackbot/​Extension.pm Registers settings and enables bug-page integration.
extensions/​Hackbot/​Config.pm Declares the Hackbot extension identity.

Review effort: Balanced

Comment thread extensions/Hackbot/lib/Client.pm Resolved
dklawren and others added 2 commits November 13, 2026 15:21
Bug 2086125.

Label each run by what started it: needinfo, @hackbot on a Phabricator
revision, Hackbot UI, CI failure, or a follow-up run, falling back to
"Hackbot".

Decode API responses as UTF-8 exactly once, and handle responses without
an ETag, which previously broke the result hash.

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

The client uses a global runs endpoint that does not support bug filtering, causing this bug’s runs to be silently omitted when they fall outside the latest 50 results.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread extensions/Hackbot/lib/Client.pm 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.

🟢 Approval recommended

No active review issues were identified for the Hackbot run-activity integration.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Xzzz Xzzz 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, thanks!
One small thing to update in the description: it still says BMO calls GET /runs?bug_id=N (mozilla/ai-dev#7440), but the code calls GET /bugs/N/runs from mozilla/ai-dev#7442.

@dklawren dklawren removed the WIP label Nov 18, 2026
@dklawren

Copy link
Copy Markdown
Collaborator Author

lgtm, thanks! One small thing to update in the description: it still says BMO calls GET /runs?bug_id=N (mozilla/bugbug#7440), but the code calls GET /bugs/N/runs from mozilla/bugbug#7442.

Thanks. Updated.

@kyoshino kyoshino 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.

Just quickly checking the UI 🙂

Comment thread extensions/Hackbot/lib/BugRuns.pm Resolved
Comment thread qa/t/rest_hackbot_runs.t Resolved
Comment thread extensions/Hackbot/lib/Config.pm Resolved
my ($class, %args) = @_;
my $self = bless {
base_url => $args{base_url} // Bugzilla->params->{hackbot_api_url},
api_key => $args{api_key} // Bugzilla->params->{hackbot_api_key},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is Bugzilla deployed on GCP with access to the meta server? If so, we could use IAM to access the Hackbot API without a key.

@dklawren dklawren Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, and worth a follow-up once we've confirmed BMO's GCP workload identity can reach the metadata server. All auth goes through Client::_get(), so switching to an ID token is a change in one place. What is the hostname of the meta server and I see if I can access it from one of the pods.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! Here's the URL: http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default

I hope we can find a Perl module that handles this for us, but if not, it's easy enough to implement ourselves.

In Python, this already works out of the box in hackbot-client.

Comment thread extensions/Hackbot/lib/BugRuns.pm Resolved
The Hackbot API's GET /bugs/{bug_id}/runs (mozilla/ai-dev#7442) now
returns slim BugRun objects: bug_id and revision_id are top-level,
inputs, requested_by, requested_via and dedupe_key are gone, and the
run's source and requester are included.

- Read the new fields, and still drop any run that is not for this bug.
- Show Hackbot's source as the origin instead of guessing it from
  dedupe keys and service accounts.
- Show the requester as plain text, with an email's domain removed.
- Default hackbot_api_url to https://hackbot-api.moz.tools/.
- Bump the run cache key to v2 for the new trimmed shape.
dklawren and others added 2 commits December 2, 2026 17:19
* origin/master: (22 commits)
  Bug 2085398 - Read flag changes from flag_activity and stop writing them to bugs_activity
  Bug 2099197 - Move Bugzilla::WebService::Constants and Bugzilla::WebService::Wants to Bugzilla::API::V1
  Bug 2097831 - Change the hackbot_needinfo_allowed group name to hackbot-users and make it a bug group with no products so it syncs to Phabricator
  Bug 2098202 - Remove the jsonrpc and rest features and the JSON::RPC and Test::Taint dependencies
  Bug 2097284 - Add a flag identifier to the subject line of emails where you are being requested for something such as needinfo, etc.
  Bumped version to 20261124.1
  Bug 2064523 - Bump jquery from 3.7.1 to 3.8.0
  Bug 2081819 - Remove the legacy REST server
  Bug 2095730 - Fix small issues in the MyDashboard, Review and BugModal API endpoints
  Bug 2094923
  Bug 2085143
  Bug 2086129 - [HACKBOT] Permission control on who can needinfo Hackbot
  Bug 1764132 - Bugzilla linkification is broken for the string https:/bugzilla.mozilla.org/home
  Bug 2094122 - Migrate extension WebService REST resources to native Mojo API
  Bug 2086133 - A needinfo webhook scoped to the webhook owner
  Bug 2085398 - Make flag_activity.who NOT NULL, add a starting flag_activity row for older flags and store the cutoff
  Bumped version to 20261118.1
  Bug 2078325
  Bug 2084590
  Bug 2084149
  ...

# Conflicts:
#	extensions/Hackbot/Config.pm
#	extensions/Hackbot/Extension.pm
#	extensions/Hackbot/lib/Config.pm
#	extensions/Hackbot/template/en/default/admin/params/hackbot.html.tmpl
#	extensions/Hackbot/template/en/default/hook/bug_modal/header-end.html.tmpl
@dklawren
dklawren merged commit 3e1244f into mozilla:master Dec 3, 2026
7 checks passed
@dklawren
dklawren deleted the 2086125 branch December 3, 2026 22:14
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.

6 participants