Skip to content

Return private typed Context errors (supersedes #1005; Docs held) - #1215

Draft
sidneyswift wants to merge 6 commits into
mainfrom
codex/context-typed-errors
Draft

sidneyswift wants to merge 6 commits into
mainfrom
codex/context-typed-errors

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds pending typed Context errors with nine codes, seven statuses and matching HTTP/MCP guidance. Head 46a0ae73cf6d96941394b45bc04bd572274ee665 normally merges released accounting main c37e7e4e29bd5418ae43399aa45457c5da4b6c1e into a72b47b729c3876350d07d0cbdbaaa96bb65281e.

All 18 contribution files and six pure modules remain byte-identical. All eight incoming accounting files match released main; no recovery feature imported. Unknown errors stay opaque/non-retryable, with existing exact classifications unchanged. Validation: 131 focused tests across five suites, production types, byte preservation and exact independent review passed. Unchanged broad local tests were not repeated; normal CI runs full checks.

Preserves the released accounting labels: amounts are customer charges, included services have no additional customer fee, provider costs are null/not_measured, and concepts/contingency/refinements are not budgeted. Pricing, quote fingerprints and legacy approval behavior are unchanged. Published API/Docs fixture is 7af66d00e0b6fcb7e5a2f27124d173273c973badd670430c0084809f21719458. Catalog preparation/freshness/standard-only OAuth, Context schema10b243 and valuation0e contracts remain intact.

Keep draft. Root owns merge/release order and native/intended-account/save/denial/workspace/full-ingestion gates. No previous native acceptance applies to these new heads. No browser/JSON/download/hosting403/auth/provider/access retry, ingestion activation, data/schema/import/spend action or manual deployment. Required exact-head CI must pass; see checks. Local independent review is separate from Cubic's merge-only skipped status.


Summary by cubic

Replaces the blanket 409 and fixed-message Context failures with authored code, retryable, and guidance errors that are identical across HTTP and MCP while preserving existing HTTP error, MCP message/success: false, and isError: true fields. This source-only draft is held until the owning Docs contract is accepted; it supersedes the typed-error work in #1005.

Error contract

  • Nine codes map to 403/404/409/422/503/402/500; budget_exhausted is reserved with no spend-path producer.
  • Classification uses exact API and storage message allowlists; unknown API messages are internal, unknown storage rejections are opaque storage_failed, and disabled capabilities return 503 unavailable.
  • Stored-data schema failures, generic SQL no-row errors, and catalog preparation rejections stay internal or opaque without lookup provenance.
  • Retry guidance is action-aware: read/list/plan/verify never requests a write key; uncertain writes keep the same key and unchanged input; attachment and catalog-save retries keep the exact source version and targets.
  • No raw exception messages, causes, or identifiers are returned or logged; existing enum-only diagnostics and private/no-store headers are unchanged.

Written for commit 46a0ae7. Summary will update on new commits.

View guided diff Turn on auto-fix

@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api Ready Ready Preview Nov 16, 2026 3:47pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Solid & Clean Code Warning The prior FAIL still holds at head 46a0ae7. I re-read the current source and the claims check out. Main finding: formatContextOperationError (new in this PR). `lib/context/formatContextOperatio… 1. Split formatContextOperationError (lib/context/formatContextOperationError.ts) so each function does one job: - Move the keyed-action list into a named constant or a predicate module, such as isKeyedContextAction.ts, that exports one…
Full details: Solid & Clean Code

Explanation

The prior FAIL still holds at head 46a0ae7. I re-read the current source and the claims check out. Main finding: formatContextOperationError (new in this PR). lib/context/formatContextOperationError.ts lines 17–47 span 31 lines. The SRP rule sets a limit of 20 lines per function. The function also does several jobs: - Lines 18–33 build an inline 12-item keyed action list. - Lines 34–38 pick retry guidance with a nested ternary, with the generic write guidance as an inline literal. - Lines 39–46 assemble the body and join the guidance strings. - Lines 4–14 hold the code-to-status map. The file's history points to commit 5dc71fe8 ("Return privacy-preserving typed Context operation errors"), which matches this PR's purpose. Treat it as PR-introduced. Adding an action means editing this function and getContextFailureMessage.ts. The guidance strings are split across both files. This conflicts with the DRY and OCP rules. Prior required fixes not applied: - No isKeyedContextAction predicate or getRetryGuidance module exists (ripgrep returned no matches for either name). - lib/mcp/tools/context/getContextToolResultError.ts line 20 still calls formatContextOperationError(error, action).body.guidance. The MCP path therefore takes guidance from the HTTP formatter. Secondary concern (not relied on): lib/context/buildCatalogAuditPreparation.ts is about 48 lines. Its history shows it predates this PR (commits e165405e and b7bddd14). I did not confirm this PR changed it, so it does not support the FAIL. Strengths: classifyContextOperationError.ts is short, keeps its allowlists as data, and exports one matching function. File-name and function-name matching holds for the new context files. Nesting stays within 3 levels. Scope: static reading only. I did not run tests or lint.

Resolution

  1. Split formatContextOperationError (lib/context/formatContextOperationError.ts) so each function does one job: - Move the keyed-action list into a named constant or a predicate module, such as isKeyedContextAction.ts, that exports one function. - Move retry-guidance selection into its own function, such as getRetryGuidance.ts. Keep all action-specific guidance in one place, not split between this file and getContextFailureMessage.ts. - Keep formatContextOperationError to status lookup and body assembly, at 20 lines or fewer. 2. Point lib/mcp/tools/context/getContextToolResultError.ts at the shared guidance function, not at formatContextOperationError(...).body.guidance. 3. Optional: move the action extraction in lib/mcp/tools/context/handleContextToolOperation.ts into a small helper. 4. Optional: move the duplicated "fetch failed" mapping in lib/context/classifyContextOperationError.ts into one shared constant. 5. Optional: if this PR changed buildCatalogAuditPreparation.ts, split it into smaller builders, for example one for sources and one for assessments.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch was successfully deployed

1 active deployment
Preview — 46a0ae73 Deployed Nov 16, 2026 by vercel[bot]
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