Repository navigation
feat(import): keep the bank's own code when a request is refused - #188
Merged
Merged
Conversation
A refused request was traced by its HTTP status alone, which cannot tell an expired aggregator session from a revoked one, or a one-off 400 from a fault. The requester now reads at most 4 KB of a refusal's body before cancelling it and, when it is JSON with a string `error` field, reports that value as `reason` beside `status` and `code`. `sanitizeReason` upper-cases it, cuts it to forty characters and keeps it only when nothing but `[A-Z0-9_]` remains, dropping anything else whole; `message` and `detail` are never read and the body is never written to stderr or to the raised error. The step type, the recorder's forwarder and the run screen carry the field. Tests cover an allowed code, a free-text value dropped whole, a non-JSON body, an empty body and a body past the bound. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
What
A refused bank request was traced by its HTTP status alone, which cannot tell an expired aggregator session from a revoked one, or a one-off 400 from a fault. Two connections latched for review on 20–21 October on the same path and the trace could not say why.
src/connectors/http.ts: on a non-OK response, read at most 4 KB of the body before cancelling it; if it parses as JSON with a stringerrorfield, report it asreasonbesidestatusandcode.sanitizeReasonupper-cases, cuts to 40 characters and keeps the value only when it matches^[A-Z0-9_]+$; anything else (a sentence, an identifier with dashes) is dropped whole, never stripped.messageanddetailare never read. A body that is empty, non-JSON, past the bound or unreadable gives no reason, and the status-based classification is unchanged either way. Nothing from the body reaches stderr or the raised error.src/import-runs.ts:AttemptStep.reason(optional).src/sync-cli.ts: the recorder forwarder carries it intobank_sync_attempts.steps.src/sync-failure.tsneeds no change: it reads onlycodefrom thebank_sync_failedline, and the reason is not written there.frontend/src/ImportRun.tsx: the run screen shows "the bank said EXPIRED_SESSION" beside the error code.docs/import-runs.mdanddocs/STATUS.mddescribe the field and its bounds.Tests
test/import-runs.test.ts: allowed code (expired_session→EXPIRED_SESSION, message absent from the event), free-text value dropped whole, non-JSON body, empty body, body past the 4 KB bound, andsanitizeReasonunit cases (bound at 40, non-strings, empty string).Commands run
Result: exit 0.
scripts/check_repository.py: Foundation checks passed (561 Git-visible files).prettier --check: All matched files use Prettier code style!pnpm test: tests 735, pass 730, fail 0 (remaining are skipped/todo, unchanged).pnpm build:frontend: built in 1.03s.scripts/check_frontend.py: entry 114 KB gzip; design rules hold.Not released; nothing deployed.
🤖 Generated with Claude Code