Skip to content

feat(search-artist-links): implement Spotify adapter - #339

Merged
chiptus merged 2 commits into
mainfrom
feat/spotify-adapter-336
Aug 21, 2026
Merged

chiptus merged 2 commits into
mainfrom
feat/spotify-adapter-336

Conversation

@chiptus

@chiptus chiptus commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Adds a complete Spotify artist search implementation with Client Credentials auth, API search, and normalization.
Search failures for individual artists don't affect results for other artists.

Verification

Preconditions: Set Supabase secrets SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET in the edge function environment.

  • Call /search-artist-links with provider: "spotify" and multiple artist names; verify all artists return up to 3 candidates each.
  • Call with one artist that has no results; verify other artists' results are returned.
  • Verify normalized candidates have correct shape: { name, url, imageUrl, followers, genres }.
  • Verify a Spotify artist with 0 followers preserves the count as 0, not null.
  • Verify missing images return imageUrl: null.
  • Verify missing genres return empty array.

Stacked on #337.

Closes #336


Generated by Claude Code

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
upline Ready Ready Preview Aug 21, 2026 3:57pm

Base automatically changed from feat/search-artist-links-334 to main August 21, 2026 11:14
…rmalization

Adds a complete Spotify artist search implementation for the search-artist-links
edge function. Includes Spotify Client Credentials auth, API search integration,
and normalization to the shared Candidate type. Implements per-artist error
handling to keep partial results when one artist search fails.

Added files:
- supabase/functions/_shared/spotify-api/auth.ts: Token caching and auth
- supabase/functions/_shared/spotify-api/schemas.ts: Spotify API response types

Modified files:
- spotify-adapter.ts: Real implementation replacing stub
- normalize.ts: normalizeSpotifySearchResult function
- normalize.test.ts: Unit tests for normalization with 0-followers preservation

Closes #336
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy → stagingworkflow run
Last updated: 2026-08-21 15:58:08 UTC

  • ⏭️ DB migrations skipped (no changes)
  • Edge functions succeeded

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements the Spotify provider for the search-artist-links Supabase Edge Function by adding Spotify Client Credentials auth, Spotify search response validation, and normalization into the shared Candidate shape used by the link wizard flow.

Changes:

  • Add a Spotify Client Credentials token helper with in-memory caching.
  • Implement searchSpotify to query Spotify’s artist search API and return up to 3 normalized candidates per artist (per-artist failures are isolated).
  • Add Spotify Zod schemas plus unit tests for normalizeSpotifySearchResult.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
supabase/functions/search-artist-links/spotify-adapter.ts Implements the Spotify provider search flow (token fetch + per-artist search + normalization).
supabase/functions/search-artist-links/normalize.ts Adds normalizeSpotifySearchResult to map Spotify artists into the shared Candidate shape.
supabase/functions/search-artist-links/normalize.test.ts Adds unit tests covering Spotify normalization edge cases (missing images/genres/followers, followers=0).
supabase/functions/_shared/spotify-api/schemas.ts Introduces Zod schemas/types for Spotify artists and search responses.
supabase/functions/_shared/spotify-api/auth.ts Adds Spotify Client Credentials token acquisition with caching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread supabase/functions/search-artist-links/spotify-adapter.ts Outdated
Comment thread supabase/functions/_shared/spotify-api/auth.ts Outdated
Comment thread supabase/functions/_shared/spotify-api/auth.ts
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

Playwright test results

passed  50 passed

Details

stats  50 tests across 14 suites
duration  1 minute, 9 seconds
commit  281423b

Comment thread supabase/functions/search-artist-links/spotify-adapter.ts Outdated
…g leak

Moves credential lookup into getSpotifyAccessToken so missing config
throws (matching SoundCloud) instead of silently returning empty
candidates. Fixes expires_in falsy-zero bug and redacts access_token
from error logs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

supabase/functions/_shared/spotify-api/schemas.ts:30

  • This schema accepts {} or { artists: {} } as a valid Spotify response, so an incomplete/malformed 200 response is silently reported as a legitimate zero-result search instead of the per-artist error handled by the adapter. Spotify search responses require both artists and items; keep those containers required while leaving genuinely nullable artist fields optional.
export const SpotifySearchResponseSchema = z.object({
  artists: z
    .object({
      items: z.array(SpotifyArtistSchema).optional(),
    })
    .optional(),

@chiptus
chiptus merged commit 132b576 into main Aug 21, 2026
17 checks passed
@chiptus
chiptus deleted the feat/spotify-adapter-336 branch August 21, 2026 16:07
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.

Spotify adapter for search-artist-links

3 participants