fix(review): circuit-break REES enrichment on auth rejection - #3738
Closed
sentry[bot] wants to merge 1 commit into
Closed
fix(review): circuit-break REES enrichment on auth rejection#3738sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
JSONbored
approved these changes
Jul 6, 2026
❌ 13 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Contributor
|
Gittensory is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-code); No linked issue detected; Maintainer requires a linked issue). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
10 tasks
This was referenced Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a circuit-breaker mechanism to prevent repeated
review_context_fetch_failederrors caused by REES/v1/enrichauthentication rejections (401/403). When theREES_SHARED_SECRETis misconfigured,buildReviewEnrichmentcontinuously attempts calls to the REES service, leading to a flood of errors and unnecessary network traffic. This change introduces areesAuthRejectedflag, set byprobeReesSecretAtStartupupon 401/403 responses, whichbuildReviewEnrichmentthen checks to skip network calls and log a throttled warning, significantly reducing log noise and network requests.Scope
type(scope): short summaryConventional Commit format, for examplefeat(rees): implement circuit-breaker for auth rejections.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.UI Evidence
Required for visible UI, frontend, docs, or extension changes. Attach GitHub-hosted JPG/JPEG or PNG screenshots here; SVG screenshots are not accepted as review evidence. Use a compact table/grid of clickable thumbnails with a short state/title such as "Loaded state", "Empty state", "Error state", "Mobile layout", or "PR sidebar". Prefer annotated screenshots with a colored box, outline, arrow, or highlighter showing what changed. Recordings can be supplemental, but screenshots are still expected for visual review. Do not commit review-only screenshots, recordings, or
docs/review-evidence/**files.<a href="FULL_URL.png"><img src="FULL_URL.png" alt="Loaded state" width="240"></a>Notes
Problem: When the
REES_SHARED_SECRETon the Gittensory engine does not match the secret configured on the REES service, every call to/v1/enrichresults in a 401/403 HTTP error. While theprobeReesSecretAtStartupfunction correctly identifies and logs this mismatch at startup, it's a fire-and-forget operation. Consequently,buildReviewEnrichmentcontinues to attempt calls to the REES service for every PR review, leading to a flood ofreview_context_fetch_failederrors in Sentry and unnecessary network traffic.Solution:
reesAuthRejected, is introduced insrc/review/enrichment-wire.ts.probeReesSecretAtStartupfunction now setsreesAuthRejected = trueif it receives a 401 or 403 response from the REES/v1/pingendpoint. The error message is also updated to inform the operator that enrichment calls will be disabled until the engine is restarted with correct secrets.buildReviewEnrichmentfunction now checks thereesAuthRejectedflag at the beginning of its execution. If the flag is true, it immediately returnsundefined, effectively skipping the network call to the REES service.rees_enrich_skipped_auth_rejected) is added tobuildReviewEnrichmentto indicate that enrichment calls are being skipped due to the authentication rejection, preventing log spam while still providing visibility.This change significantly reduces log noise and unnecessary network requests when REES authentication is misconfigured, making the system more robust and easier to debug. No UI changes are involved in this PR.
Fixes GITTENSORY-D