Skip to content

fix(review): surface a non-2xx REES enrichment response to Sentry - #1646

Merged
JSONbored merged 1 commit into
mainfrom
fix/rees-non200-observability
Jun 28, 2026
Merged

fix(review): surface a non-2xx REES enrichment response to Sentry#1646
JSONbored merged 1 commit into
mainfrom
fix/rees-non200-observability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

buildReviewEnrichment returned undefined on a non-200 from the REES /v1/enrich endpoint with no log — so a broken or auth-failing enrichment backend silently degraded the review to no-enrichment with no signal (only network/timeout errors were logged). It now logs the non-2xx at error level (the same review_context_fetch_failed event as the network-error catch, with the status code) so the Sentry forwarder captures a broken REES backend.

Verified live: /v1/enrich currently returns 200 — this closes the observability gap for when it doesn't.

Scope

  • Conventional Commit; focused (enrichment-wire.ts + its test).
  • No site//CNAME/Pages.

Validation

  • npm run test:ci green; the non-200 test now asserts the error log fires (status 502).
  • npm audit --audit-level=moderate

Safety

  • No secrets in code/logs (logs the status code + repo, not the shared secret).
  • No behavior change beyond the added log (still returns undefined → review proceeds un-enriched).

buildReviewEnrichment returned undefined on a non-200 from /v1/enrich with no
log, so a broken or auth-failing REES backend silently degraded the review to
no-enrichment with no signal. Log it at error level (the same
review_context_fetch_failed event as the network-error catch) so the Sentry
forwarder captures a broken REES backend.
@dosubot dosubot Bot added the size:S label Jun 28, 2026
@loopover-orb

loopover-orb Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review — held for maintainer review

2 files · 1 AI reviewers · no blockers · readiness 66/100 · CI pending · blocked

⏸️ Held for maintainer review

Review summary
A clean, minimal observability fix: the silent `return undefined` on a non-2xx REES response is replaced with a structured `console.error` at the same `review_context_fetch_failed` event and log level as the existing `catch` block (`enrichment-wire.ts:143`), closing the gap where a broken REES backend would degrade the review invisibly. Behavior is otherwise unchanged — the function still returns `undefined` and the review proceeds un-enriched. The test exercises the real code path with a genuine non-200 stub and the assertion correctly targets both the event name and the embedded status code in the serialized JSON string.

Signal Result Evidence
Code review ✅ No blockers 1 reviewers, synthesized
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Review load ✅ 20/20 Readiness component derived from cached public PR metadata and labels; size label size:S.
Validation evidence ❌ 5/25 Cached preflight status is hold.
Open PR queue ❌ 3/10 37 open PR(s), 17 likely reviewable, 20 unlinked.
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 80 PR(s), 291 issue(s).
Gate result ✅ Passing No configured blocker found.
Nits — 5 non-blocking
  • enrichment-wire.ts:103–108: The status code is embedded only inside the `message` string (`'REES /v1/enrich returned 502'`); add `status: response.status` as a discrete field so Sentry can group and alert by numeric status without string-parsing the message — e.g. `{ ..., status: response.status, message: \`REES /v1/enrich returned ${response.status}\` }`.
  • enrichment-wire.ts:96–98: The two-line inline comment restates what the PR description already documents and is longer than the single-line WHY comments elsewhere in the file (`// Surface the failure (feat(release): add public registration polish gates #5 review observability)...`); trim to something like `// non-2xx: surface for Sentry (same event as catch) — was a silent skip`.
  • test/unit/enrichment-wire.test.ts:103,109: `errSpy.mockRestore()` sits in the test body, so the spy leaks if any assertion between setup and cleanup throws; this is a pre-existing pattern in the file (the `feat(release): add public registration polish gates #5` test at line 113 has the same shape) but the new test reproduces it — a `try/finally` block or moving spy lifecycle into `beforeEach`/`afterEach` would make the suite more robust.
  • enrichment-wire.ts:103: Add `status: response.status` as a discrete numeric field in the JSON payload so Sentry can filter and aggregate by HTTP status as a structured tag rather than by parsing a free-text message string.
  • test/unit/enrichment-wire.test.ts: Wrap the errSpy teardown in `try/finally { errSpy.mockRestore() }` to prevent spy leakage on assertion failures — the existing `feat(release): add public registration polish gates #5` network-error test could get the same treatment in a follow-up.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 80 PR(s), 291 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Fix blocker.
  • Expect slower review.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review details

Generated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative.

A clean, minimal observability fix: the silent `return undefined` on a non-2xx REES response is replaced with a structured `console.error` at the same `review_context_fetch_failed` event and log level as the existing `catch` block (`enrichment-wire.ts:143`), closing the gap where a broken REES backend would degrade the review invisibly. Behavior is otherwise unchanged — the function still returns `undefined` and the review proceeds un-enriched. The test exercises the real code path with a genuine non-200 stub and the assertion correctly targets both the event name and the embedded status code in the serialized JSON string.

Nits (5)

  • enrichment-wire.ts:103–108: The status code is embedded only inside the `message` string (`'REES /v1/enrich returned 502'`); add `status: response.status` as a discrete field so Sentry can group and alert by numeric status without string-parsing the message — e.g. `{ ..., status: response.status, message: \`REES /v1/enrich returned ${response.status}\` }`.
  • enrichment-wire.ts:96–98: The two-line inline comment restates what the PR description already documents and is longer than the single-line WHY comments elsewhere in the file (`// Surface the failure (feat(release): add public registration polish gates #5 review observability)...`); trim to something like `// non-2xx: surface for Sentry (same event as catch) — was a silent skip`.
  • test/unit/enrichment-wire.test.ts:103,109: `errSpy.mockRestore()` sits in the test body, so the spy leaks if any assertion between setup and cleanup throws; this is a pre-existing pattern in the file (the `feat(release): add public registration polish gates #5` test at line 113 has the same shape) but the new test reproduces it — a `try/finally` block or moving spy lifecycle into `beforeEach`/`afterEach` would make the suite more robust.
  • enrichment-wire.ts:103: Add `status: response.status` as a discrete numeric field in the JSON payload so Sentry can filter and aggregate by HTTP status as a structured tag rather than by parsing a free-text message string.
  • test/unit/enrichment-wire.test.ts: Wrap the errSpy teardown in `try/finally { errSpy.mockRestore() }` to prevent spy leakage on assertion failures — the existing `feat(release): add public registration polish gates #5` network-error test could get the same treatment in a follow-up.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb

loopover-orb Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Important

🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪

🔍 Gittensory is reviewing…

AI analysis is in progress. This comment will update when the review is complete.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jun 28, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@298014a). Learn more about missing BASE report.
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1646   +/-   ##
=======================================
  Coverage        ?   95.53%           
=======================================
  Files           ?      204           
  Lines           ?    22115           
  Branches        ?     7985           
=======================================
  Hits            ?    21128           
  Misses          ?      412           
  Partials        ?      575           
Files with missing lines Coverage Δ
src/review/enrichment-wire.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 8585e88 into main Jun 28, 2026
19 checks passed
@JSONbored
JSONbored deleted the fix/rees-non200-observability branch June 28, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant