fix: enrich the create-time Spotify attach with the real profile - #796
fix: enrich the create-time Spotify attach with the real profile#796sweetmantech wants to merge 1 commit into
Conversation
resolveOrCreateArtist's create path saved the URL path segment as the username, so verify-socials rendered 'Spotify @artist · 0 followers'. Fetch the real Spotify profile after the attach and reuse enrichSearchedArtistProfile to write the real handle, follower count and avatar. chat#1889 row 16. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 16 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
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. Comment |
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Caller as Caller (resolveOrCreateArtist)
participant Resolve as resolveOrCreateArtist
participant Social as updateArtistSocials
participant Enrich as enrichArtistSpotifyProfile (NEW)
participant Token as generateAccessToken
participant Spotify as getArtist (Spotify API)
participant EnrichProfile as enrichSearchedArtistProfile
Note over Caller,Resolve: Create path (no canonical artist exists)
Caller->>Resolve: resolveOrCreateArtist(params)
Resolve->>Resolve: Create artist in DB, insert account-artist link
alt attach succeeds (social link created)
Resolve->>Social: updateArtistSocials(account_id, { SPOTIFY: url })
Social-->>Resolve: success
Note over Resolve: NEW: Enrich the just-attached social
Resolve->>Enrich: enrichArtistSpotifyProfile({ artistId, spotifyArtistId })
alt token minted successfully
Enrich->>Token: generateAccessToken()
Token-->>Enrich: { access_token: "tok", error: null }
alt profile fetched successfully
Enrich->>Spotify: getArtist(spotifyArtistId, token)
Spotify-->>Enrich: { artist: realProfile }
Enrich->>EnrichProfile: enrichSearchedArtistProfile({ artistId, spotifyArtistId, spotifyArtist })
Note over EnrichProfile: Updates social handle/followers/avatar
EnrichProfile-->>Enrich: void
Enrich-->>Resolve: void (enrichment done)
else profile fetch fails
Spotify-->>Enrich: { artist: null, error: ... }
Note over Enrich: NEW: Best-effort skip, leave social fixable later
Enrich-->>Resolve: void (no enrich)
end
else token mint fails
Token-->>Enrich: { access_token: null, error: ... }
Note over Enrich: NEW: Best-effort skip
Enrich-->>Resolve: void (no enrich)
end
Note over Enrich: NEW: Any exception caught inside, never throws
Resolve-->>Caller: { artist: created, created: true }
else attach fails (exception)
Social-->>Resolve: (throws)
Note over Resolve: Social attach failed – nothing to enrich, skip
Resolve-->>Caller: (caught, returns empty result or fallback)
end
Note over Caller,Resolve: Canonical link path (unchanged) – not depicted
Auto-approved: Focused bug fix that corrects create-time Spotify social metadata to show real handle/followers/avatar. Bounded to the create path, best-effort, uses existing enrichment, and has thorough tests.
Re-trigger cubic
Summary
Row 16 of chat#1889: a social saved by
resolveOrCreateArtist's create path persistedusername: "artist"(the URL path segment),followerCount: 0and no avatar, so verify-socials renderedSpotify @artist · 0 followersfor an artist with 1.8M followers. Scope was narrowed 2026-07-29: the junk metadata comes only from this create-time attach; the social-fix/re-add path already writes real metadata (proven on chat#1894's preview walk).What it does
lib/artists/enrichArtistSpotifyProfile.ts(new, SRP): mint a Spotify app token →getArtist→ delegate to the existingenrichSearchedArtistProfile(the same enrichmentrunValuationHandleruses, which already handles the normalized-profile_url upsert). Best-effort: never throws; skips cleanly when the token or profile fetch fails, leaving the social fixable in verify-socials.resolveOrCreateArtist: after the create-pathupdateArtistSocialsattach succeeds, enrich with the real handle/followers/avatar. Inside the same try block — a failed attach leaves nothing to enrich. Canonical-link path unchanged (its social already carries real metadata).Tests (TDD, red→green)
lib/artists/__tests__/enrichArtistSpotifyProfile.test.ts(delegates with the fetched profile; skips on token failure; skips on profile-fetch failure; never throws)resolveOrCreateArtist.test.ts(enriches on create; not on plain create; not when the attach fails)tsc --noEmitat the 236-error pre-existing baseline (none in touched files); eslint cleanIndependent of the row 15 chain — no migration dependency. Tracked in chat#1889 row 16.
🤖 Generated with Claude Code
Summary by cubic
Fix incorrect Spotify social metadata on newly created artists by enriching the attach with the real profile right after creation. verify-socials now shows the real handle, follower count, and avatar.
enrichArtistSpotifyProfileto mint a token, fetch the Spotify artist viagetArtist, and delegate toenrichSearchedArtistProfile(best-effort, never throws).resolveOrCreateArtistto call enrichment immediately afterupdateArtistSocialson the create path, only when a Spotify ID is present and the attach succeeds.Written for commit 951782c. Summary will update on new commits.