Skip to content

fix: Go to Artist shows 400 error for home page items#111

Merged
sozercan merged 1 commit intomainfrom
fix/go-to-artist-invalid-id
Feb 24, 2026
Merged

fix: Go to Artist shows 400 error for home page items#111
sozercan merged 1 commit intomainfrom
fix/go-to-artist-invalid-id

Conversation

@sozercan
Copy link
Owner

@sozercan sozercan commented Feb 24, 2026

Problem

Right-clicking items in "Listen Again" (and similar home sections) and selecting "Go to Artist" navigates to a non-existent artist page, resulting in a 400 Server Error.

Root Cause

Home page items (musicTwoRowItemRenderer) have subtitle runs with no navigationEndpoint per artist — all artists are a single comma-separated string:

"subtitle": { "runs": [{ "text": "Taylor Swift, Justin Bieber, ..." }] }

ParsingHelpers.extractArtists() generates a SHA256 hash ID for these (e.g., "a1b2c3d4e5f6..."). The old hasNavigableId check (!id.contains("-")) passed for these hex strings, but they are not valid YouTube Music channel IDs — causing a 400 when the API is called.

Confirmed via api-explorer.swift browse FEmusic_home -v — subtitle runs in home carousel items have hasNav=false, browseId="".

Fix

File Change
Core/Models/Artist.swift hasNavigableId now checks id.hasPrefix("UC") instead of !id.contains("-")
Views/macOS/HomeView.swift Use hasNavigableId + first(where:) (consistent with other views)
Views/macOS/SharedViews/FavoritesSection.swift Same inline check replaced with hasNavigableId
Core/Services/ShareService.swift Simplified redundant guard (UC prefix check is sufficient)
Tests/KasetTests/ModelTests.swift 4 new tests: UC IDs, hash IDs, UUIDs, empty IDs
docs/common-bug-patterns.md New anti-pattern: "Treating Generated IDs as Navigable API IDs"

Testing

  • All 566 unit tests pass
  • Build succeeds
  • swiftlint --strict: 0 violations
  • swiftformat: 0 files reformatted

Home page items (Listen Again, Albums for you, etc.) have subtitle runs
with no navigationEndpoint per artist. ParsingHelpers.extractArtists()
generates SHA256 hash IDs for these, which incorrectly passed the old

- Update Artist.hasNavigableId to check for UC prefix (real channel IDs)
- Update HomeView and FavoritesSection to use hasNavigableId consistently
- Simplify redundant guard in ShareService.shareURL
- Add 4 unit tests for hasNavigableId (UC, hash, UUID, empty)
- Document the anti-pattern in common-bug-patterns.md
Copilot AI review requested due to automatic review settings February 24, 2026 07:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where clicking "Go to Artist" on home page items resulted in 400 errors. The root cause was that home page items without navigation endpoints generate SHA256 hash IDs, which were incorrectly passing the old validation check (!id.contains("-")). The fix updates the validation to explicitly check for the "UC" prefix that all valid YouTube channel IDs have.

Changes:

  • Updated Artist.hasNavigableId to use id.hasPrefix("UC") instead of !id.contains("-")
  • Updated HomeView and FavoritesSection to use the hasNavigableId property with first(where:) pattern
  • Simplified ShareService guard by removing redundant hyphen check
  • Added comprehensive test coverage and documentation

Reviewed changes

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

Show a summary per file
File Description
Core/Models/Artist.swift Changed hasNavigableId from hyphen check to UC prefix check
Views/macOS/HomeView.swift Uses hasNavigableId with first(where:) for consistent artist filtering
Views/macOS/SharedViews/FavoritesSection.swift Same pattern as HomeView for consistency
Core/Services/ShareService.swift Simplified guard to only check UC prefix
Tests/KasetTests/ModelTests.swift Added 4 tests covering UC IDs, hash IDs, UUIDs, and empty strings
docs/common-bug-patterns.md Documented the anti-pattern with clear examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sozercan sozercan merged commit 1f27296 into main Feb 24, 2026
10 checks passed
@sozercan sozercan deleted the fix/go-to-artist-invalid-id branch February 24, 2026 08:10
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