Skip to content

feat(sentry-monitor): classify gateway-relayed upstream 5xx vs gateway-origin 5xx (ENG-16922) - #89

Merged
convyusboy merged 2 commits into
boonfrom
ridho/eng-16922-5xx-source-classification
Jul 30, 2026
Merged

convyusboy merged 2 commits into
boonfrom
ridho/eng-16922-5xx-source-classification

Conversation

@convyusboy

@convyusboy convyusboy commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Related: ENG-16922 (builds on #83 / ENG-16815)

What Problem This Solves

The Rohan "Boon Agent 5xx error(s) detected" Sentry alert (openclaw-fleet project → #engineering-rohan-urgent-alert) pages with blanket copy "5xx = our infra. Investigate." In the 2026-07-28 incident, every alerted correlation ID was an AWS Bedrock 5xx relayed verbatim by boon-llm-gateway (status=500/503 error_type="api_error") — a self-recovering provider blip, not Boon infra. Every such page sent on-call down a host-triage path for something no host action can fix.

The fleet runs single-hop, where the gateway relays the upstream error verbatim and never self-captures to Sentry — so the page comes from this plugin's model_call_ended hook, which had no HTTP status to tell a relayed provider outage from a gateway-origin fault.

Why This Change Was Made

The classification data exists in the runtime post-#83 (the numeric HTTP status is preserved on the thrown error), but it was never threaded into the model_call_ended hook the sentry-monitor plugin consumes. This PR closes that gap so the alert can distinguish — and later rate-gate — the two classes.

  1. classify5xxSource() (src/infra/diagnostic-error-metadata.ts) — status-driven, no free-text message regex (the fragility fix: transient upstream 5xx (gateway-relayed Bedrock 503) now fails over instead of blocking the customer #83 deliberately removed):
    • 500 / 503 / 529 → upstream_provider_5xx (Bedrock/Anthropic relayed)
    • 502 / other 5xx → gateway_origin_5xx (gateway-synthesized: chain exhausted, WAF/HTML block, no-response transport fault)
    • a recognized api_error / overloaded provider error.type forces the upstream class on an ambiguous status (tie-break, own-data-prop read only — no userland getters)
    • undefined for a missing or non-5xx status
      The split mirrors the gateway's single-hop behavior: a real upstream 5xx is relayed verbatim, and the gateway only synthesizes 502 for its own faults.
  2. Add optional httpStatus + errorClass to PluginHookModelCallEndedEvent and the model.call.error diagnostic event; populate both in modelCallErrorFields.
  3. Tag error_class + extra.http_status in buildModelCallEndedCapture, and lead the Sentry title with them so the two classes fingerprint into separate issues.

User / Operator Impact

An operator (and the Sentry alert rule) can now split a relayed Bedrock outage from a genuine gateway fault — page tightly on gateway_origin_5xx, rate-gate a low background of upstream_provider_5xx. Additive, optional fields; no change to failover behavior. The alert threshold/rate-gate/copy are Sentry-UI-configured and land after this ships fleet-wide (sequencing + Sentry steps in the gandalf-manager spec docs/specs/2026-07-29-eng16922-5xx-source-classification.md).

Verification

  • New unit tests: classify5xxSource (status bands, tie-break, getter-safety, non-5xx → undefined) and buildModelCallEndedCapture (relayed-503 ⇒ upstream_provider_5xx, synthesized-502 ⇒ gateway_origin_5xx, non-5xx ⇒ tag absent, title reflects the class).
  • pnpm tsgo:prod clean (EXIT 0); oxlint clean on touched files; 57 targeted tests pass.

🤖 Generated with Claude Code


Summary by cubic

Classifies 5xx errors as upstream_provider_5xx vs gateway_origin_5xx and threads httpStatus + errorClass through model_call_ended so Sentry tags, titles, and fingerprints split by source. This lets the Rohan 5xx alert page on gateway faults and rate‑gate relayed Bedrock outages (ENG-16922).

  • New Features
    • Add classify5xxSource(status, err):
      • 500/503/529 → upstream_provider_5xx; 502/other 5xx → gateway_origin_5xx
      • Tie-break on provider error.type in {api_error, overloaded, overloaded_error} → upstream
      • Non-5xx → unset
    • Include httpStatus and errorClass in diagnostic and hook events; tag Sentry error_class and extra.http_status, and lead the title with them to split issues.
    • Update sentry-monitor docs with the tag table and tie-break types; add targeted tests for classification and capture output.

Written for commit ce9b094. Summary will update on new commits.

Review in cubic

…y-origin 5xx (ENG-16922)

The Rohan "Boon Agent 5xx error(s) detected" alert (openclaw-fleet Sentry
project) pages with blanket "5xx = our infra. Investigate." copy — but the
fleet runs single-hop, where boon-llm-gateway relays an upstream Bedrock 5xx
verbatim and never self-captures. The page comes from this plugin's
model_call_ended hook, which had no HTTP status to tell a relayed provider
outage from a gateway-origin fault.

Thread the numeric HTTP status (available on the thrown error post-#83) and a
status-derived source class through the model_call_ended hook, and tag the
Sentry capture with it so the alert can split/rate-gate the two:

- classify5xxSource() in diagnostic-error-metadata.ts: status-driven (no
  message regex), 500/503/529 -> upstream_provider_5xx, 502/other-5xx ->
  gateway_origin_5xx, with a recognized api_error/overloaded provider
  error.type as an ambiguous-status tie-break.
- Add httpStatus + errorClass to PluginHookModelCallEndedEvent and the
  model.call.error diagnostic event; populate both in modelCallErrorFields.
- Tag error_class + extra.http_status in buildModelCallEndedCapture; lead the
  Sentry title with them so the two classes fingerprint into separate issues.
- Tests for classify5xxSource + the capture; docs/gateway/sentry-monitor.md
  tag table + note.

The alert threshold/rate-gate/copy are Sentry-UI-configured and land after
this ships fleet-wide (see gandalf-manager spec
docs/specs/2026-07-29-eng16922-5xx-source-classification.md).

tsgo:prod clean; oxlint clean; 57 targeted tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude

claude Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai Bot 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.

cubic analysis

All reported issues were addressed across 9 files

Linked issue analysis

Linked issue: ENG-16922: Rohan 5xx alert: distinguish upstream-provider (Bedrock) 5xx from gateway-origin 5xx

Status Acceptance criteria Notes
✅ Add classify5xxSource() that maps 500/503/529 → upstream_provider_5xx, 502/other 5xx → gateway_origin_5xx, uses provider error.type (api_error/overloaded*) as tie-break, and returns undefined for non-5xx. Function implemented with status bands, provider-type tie-break, own-data-property reads, and non-5xx returns undefined.
✅ Thread httpStatus and errorClass into diagnostic model-call error fields and plugin hook (so downstream observers can read them). Diagnostic event types and plugin hook types were extended and modelCallErrorFields now extracts and populates httpStatus and errorClass.
✅ Tag Sentry captures with error_class and include extra.http_status; lead the Sentry message/title with class + status so they fingerprint separately. buildModelCallEndedCapture now includes error_class in tags and http_status in extra; describeModelCallError composes message parts with errorClass/httpStatus.
✅ Provide unit tests verifying classify5xxSource behavior and that captures carry tags/extra/message for upstream vs gateway 5xx and omit the class when absent. New tests cover status bands, tie-breaks, getter-safety, and capture expectations (tags/extra/message) and an omission case.
✅ Update docs to mention error_class and http_status and explain intended alert behavior for upstream vs gateway 5xx. The sentry-monitor docs were updated to list error_class in the model_call_ended tags and describe classification purpose and usage.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/infra/diagnostic-error-metadata.ts Resolved
Comment thread src/infra/diagnostic-error-metadata.ts Resolved
Comment thread docs/gateway/sentry-monitor.md Resolved
…eak types (ENG-16922)

Address cubic review P3: the classify5xxSource tie-break matches
api_error/overloaded/overloaded_error (UPSTREAM_PROVIDER_ERROR_TYPES), but the
doc listed only api_error/overloaded.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@gandalfboon gandalfboon Bot 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.

Approving — clean, well-scoped fix for ENG-16922.

Verified live:

  • Ran the targeted suites on the PR branch: 47/47 pass (classify5xxSource status-bands/tie-break/getter-safety/non-5xx + buildModelCallEndedCapture relayed-503/synth-502/non-5xx tag+title).
  • CI check-prod-types + check-lint + all boundary/quality checks green.

What I like:

  • Status-driven classification with no message regex — respects the fragility ENG-16815 deliberately removed.
  • Getter-safe throughout (readOwnDataProperty reads own data descriptors only; the getter-safety test proves it).
  • Tie-break recurses into error/cause so a relayed provider api_error body wins over the synthesized-502 heuristic — internally consistent with the single-hop model.
  • Conservative default (unknown 5xx → gateway_origin_5xx) is the right bias: page on our infra, rate-gate provider blips.
  • Fields are additive + optional; no change to failover behavior; docs tag-table updated (incl. the overloaded_error P3 follow-up).

No blocking issues.

@convyusboy
convyusboy merged commit 424f5b4 into boon Jul 30, 2026
259 of 261 checks passed
@convyusboy
convyusboy deleted the ridho/eng-16922-5xx-source-classification branch July 30, 2026 08:16
convyusboy added a commit that referenced this pull request Jul 30, 2026
Version-bump release carrying the 3 commits merged onto boon since boon.11:

- #86: edge/WAF HTML 429 now classifies as transient timeout (not model
  rate_limit), so a Cloudflare-relayed 429 no longer surfaces a false
  'all models rate-limited'; the client-side ride-out retry still absorbs it.
- #88: DEBUG-level trace of the Slack thread-resolution decision on the agent
  message-send tool path (sendMessage/uploadFile); observability only, no
  behavior change, message content never logged.
- #89: sentry-monitor classifies gateway-relayed upstream (Bedrock) 5xx vs
  gateway-origin 5xx via classify5xxSource(), tagging error_class + http_status
  on the model_call_ended capture so the Rohan alert can split/rate-gate them.

Bumps the gateway + @openclaw/slack + @openclaw/msteams to 2026.6.11-boon.12 in
lockstep (7 files: 3 package.json, 3 npm-shrinkwrap.json, CHANGELOG.md). Tagging
v2026.6.11-boon.12 after merge triggers boon-release.yml to publish the 6 assets.
convyusboy added a commit that referenced this pull request Jul 31, 2026
…ease asset (ENG-15788) (#94)

* release: 2026.6.11-boon.12

Version-bump release carrying the 3 commits merged onto boon since boon.11:

- #86: edge/WAF HTML 429 now classifies as transient timeout (not model
  rate_limit), so a Cloudflare-relayed 429 no longer surfaces a false
  'all models rate-limited'; the client-side ride-out retry still absorbs it.
- #88: DEBUG-level trace of the Slack thread-resolution decision on the agent
  message-send tool path (sendMessage/uploadFile); observability only, no
  behavior change, message content never logged.
- #89: sentry-monitor classifies gateway-relayed upstream (Bedrock) 5xx vs
  gateway-origin 5xx via classify5xxSource(), tagging error_class + http_status
  on the model_call_ended capture so the Rohan alert can split/rate-gate them.

Bumps the gateway + @openclaw/slack + @openclaw/msteams to 2026.6.11-boon.12 in
lockstep (7 files: 3 package.json, 3 npm-shrinkwrap.json, CHANGELOG.md). Tagging
v2026.6.11-boon.12 after merge triggers boon-release.yml to publish the 6 assets.

* feat(release): publish @openclaw/diagnostics-prometheus as a fork release asset (ENG-15788)

The diagnostics-prometheus plugin's dist is excluded from the published gateway
package (`!dist/extensions/diagnostics-prometheus/**`), so a fleet host has no
way to run the Prometheus exporter unless the plugin is installed separately —
and gandalf-manager's Alloy scrape (job boon-agent-openclaw, ENG-15788 step 2)
has nothing to read until it is. There was no release tarball for it.

- Pin extensions/diagnostics-prometheus/package.json + npm-shrinkwrap.json to
  2026.6.11-boon.12 in lockstep with the gateway (same contract as slack/msteams
  — the pack step asserts TAG == v<version>).
- Add a 'Pack diagnostics-prometheus plugin tarball + compute sha256' step to
  boon-release.yml mirroring the slack/msteams steps (runtime-build + manifest
  overlay pack), and wire the new asset + its .sha256 into the Publish step (both
  create and upload --clobber arms) so it ships on the same v*-boon.N tag.

Asset contract:
  openclaw-diagnostics-prometheus-<version>.tgz + .tgz.sha256

Unlike slack/msteams this plugin does NOT use openKeyedStore (no trust-gate), so
a bare install wouldn't crash-loop — but the npm-pack: trusted path is used for
install-shape consistency across the fork's plugins. Version must advance in
lockstep on every future release, same as slack/msteams. actionlint clean; YAML
valid. Pack machinery validated by CI on the release run (no node_modules in this
worktree to pack locally).
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.

1 participant