Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Addressed feedback on PR #180 regarding the use of ky vs instance() in src/helpers/musicbrainz.ts.

Analysis

The instance() function from @/api is designed exclusively for Spotify API calls:

  • Configured with Spotify Bearer token authentication
  • Automatic token refresh on 401 responses
  • Hardcoded Spotify API base URL

MusicBrainz (and other external APIs like Discogs, Wikidata) require:

  • Different base URLs and authentication mechanisms
  • Custom headers (User-Agent for MusicBrainz, Discogs token for Discogs)
  • No Spotify credentials

Current Implementation Pattern

External APIs consistently use ky.create() with custom configuration:

// src/helpers/musicbrainz.ts
const musicbrainzClient = ky.create({
  headers: { "User-Agent": USER_AGENT },
  prefixUrl: MUSICBRAINZ_API_URL,
  retry: { limit: 1, statusCodes: [429, 503] },
  timeout: 10000,
});

Using instance() would send Spotify auth tokens to third-party APIs, creating both functional and security issues.

Requested Clarification

Awaiting guidance on whether a different abstraction pattern is desired for external API clients while maintaining proper authentication isolation.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update Discogs and Wikipedia/Wikidata support based on PR feedback Clarify API client pattern for external third-party APIs Dec 9, 2025
Copilot AI requested a review from BeardedBear December 9, 2025 22:15
@BeardedBear BeardedBear closed this Dec 9, 2025
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.

2 participants