Skip to content

Persist bounded Spotify ingest recovery guidance (supersedes #1001) - #1216

Draft
sidneyswift wants to merge 4 commits into
mainfrom
codex/context-ingest-recovery
Draft

sidneyswift wants to merge 4 commits into
mainfrom
codex/context-ingest-recovery

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds seven pending authored recovery texts to the existing stored request.error field. Head 1fff5274fdab922aadbc254b23bfc96b0a2cb4d0 normally merges released accounting main c37e7e4e29bd5418ae43399aa45457c5da4b6c1e into 89c2e1a341ccefa25499e1ea70309c4a3a438edd.

All ten contribution files and three pure modules remain byte-identical. All eight incoming accounting files match released main; no typed feature imported. Recovery texts, privacy, claim/auth ordering and retry limits are unchanged. Validation: 143 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

Persists bounded, classified Spotify ingest recovery guidance through the existing fail_context_request RPC, replacing the single generic failure message.

  • Stores one of seven codes with conditional retry guidance; persisted text never carries provider bodies, exception details, IDs, or logs: unsupported_input, recording_unavailable, provider_outage, provider_rejected, provider_response_invalid, identity_conflict, unknown.
  • Album and playlist/artist URLs now return explicit schema-level HTTP 400 routing messages, pointing albums to ingest_release and naming playlists and artist pages as unsupported track inputs.
  • Classifies only standard fetch failures, JSON/schema decode, and exact storage identity conflicts; everything else stays unknown.
  • 404/410 is not presented as proof of deletion, and unknown or lost commit responses do not claim zero writes.
  • Verified end to end through the real stored-request adapter, confirming the same claim token is reused across calls and no provider body leaks into a persisted error.

Written for commit 1fff527. 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 check fails on SRP, DRY, and clean-code criteria. I confirmed these at HEAD 1fff527 with the diff from base 0b1450b. Function length and multiple responsibilities (SRP): - `lib/context/fetch… Refactor the changed boundaries so each function stays near the 20-line guideline and does one job. 1. In fetchSpotifyContext.ts, move each concern into a named function. Use one primary function per file, with the file named after that f…
Full details: Solid & Clean Code

Explanation

The check fails on SRP, DRY, and clean-code criteria. I confirmed these at HEAD 1fff527 with the diff from base 0b1450b. Function length and multiple responsibilities (SRP): - lib/context/fetchSpotifyContext.ts lines 26–106 span 81 lines. The criteria set a 20-line guideline. - The base function (lines 26–63) was about 38 lines. The PR added the transport-error classification (lines 40–47), HTTP status mapping (lines 48–58), JSON decode classification (lines 59–71), schema-failure mapping (lines 72–77), and the identity-conflict throw (lines 79–83). - One function now handles network, HTTP, decode, validation, identity, and result mapping. The PR increased the existing length violation. Duplication (DRY): - The predicate error instanceof DOMException && ["TimeoutError", "AbortError"].includes(error.name) appears at lines 42 and 68. The base file had neither copy, so the PR introduced both. - The status groups are inline literals (404 || 410 at line 51, 429 || >= 500 at line 53), with no named constants. - The message "Use a Spotify track or a single YouTube video URL" appears at parseContextUrl.ts:47 and schema.ts:33. The parseContextUrl.ts copy is new in this PR. The message is not exported from one constant. Readability (clean code, KISS): - parseContextUrl.ts lines 30–36 contain a three-level nested ternary that selects the Spotify routing message. It mixes URL parsing with user-facing message selection. The file grew from 34 lines in the base to 49 lines. Passing criteria: - The new files classifyContextIngestFailure.ts, describeContextIngestFailure.ts, and ContextIngestFailure.ts follow the file-name rule and are small. The classifier and describer are single-purpose. - No new named function was added to an existing file. Prior failure disposition: The prior FAIL still applies. The fetchSpotifyContext.ts and parseContextUrl.ts content is unchanged from the state the prior run described. The duplicated predicate, unnamed status groups, duplicated message, and nested ternary are all still present. The author is sidneyswift. Authorship is not part of this check.

Resolution

Refactor the changed boundaries so each function stays near the 20-line guideline and does one job. 1. In fetchSpotifyContext.ts, move each concern into a named function. Use one primary function per file, with the file named after that function. Candidates: - a transport-error classifier, such as classifySpotifyTransportError.ts; - an HTTP status mapper, such as mapSpotifyStatusToFailureCode.ts; - a body decoder, such as decodeSpotifyTrackBody.ts; - an identity check. Keep fetchSpotifyContext as a short orchestrator. 2. Replace the duplicated ["TimeoutError", "AbortError"] predicate with one shared helper or constant. Use it at both call sites (lines 42 and 68). 3. Name the status-code groups. Use a constant set for 404/410 and a named predicate for 429/5xx. 4. In parseContextUrl.ts, move Spotify routing message selection into a small function or a lookup object keyed by entity kind. Remove the nested ternary. 5. Export "Use a Spotify track or a single YouTube video URL" from one constant. Import it in parseContextUrl.ts and schema.ts. 6. Optional: split __tests__/ingestFailureStates.test.ts into focused files by failure code.

  • 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 — 1fff5274 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