Repository navigation
Persist bounded Spotify ingest recovery guidance (supersedes #1001) - #1216
sidneyswift wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | 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.tslines 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 predicateerror 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 || 410at line 51,429 || >= 500at line 53), with no named constants. - The message "Use a Spotify track or a single YouTube video URL" appears atparseContextUrl.ts:47andschema.ts:33. TheparseContextUrl.tscopy is new in this PR. The message is not exported from one constant. Readability (clean code, KISS): -parseContextUrl.tslines 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 filesclassifyContextIngestFailure.ts,describeContextIngestFailure.ts, andContextIngestFailure.tsfollow 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. ThefetchSpotifyContext.tsandparseContextUrl.tscontent 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 issidneyswift. 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 asclassifySpotifyTransportError.ts; - an HTTP status mapper, such asmapSpotifyStatusToFailureCode.ts; - a body decoder, such asdecodeSpotifyTrackBody.ts; - an identity check. KeepfetchSpotifyContextas 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. InparseContextUrl.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 inparseContextUrl.tsandschema.ts. 6. Optional: split__tests__/ingestFailureStates.test.tsinto 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.
Adds seven pending authored recovery texts to the existing stored request.error field. Head
1fff5274fdab922aadbc254b23bfc96b0a2cb4d0normally merges released accounting mainc37e7e4e29bd5418ae43399aa45457c5da4b6c1einto89c2e1a341ccefa25499e1ea70309c4a3a438edd.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_requestRPC, replacing the single generic failure message.unsupported_input,recording_unavailable,provider_outage,provider_rejected,provider_response_invalid,identity_conflict,unknown.ingest_releaseand naming playlists and artist pages as unsupported track inputs.unknown.Written for commit 1fff527. Summary will update on new commits.