fix: Go to Artist shows 400 error for home page items#111
Merged
Conversation
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
There was a problem hiding this comment.
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.hasNavigableIdto useid.hasPrefix("UC")instead of!id.contains("-") - Updated HomeView and FavoritesSection to use the
hasNavigableIdproperty withfirst(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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 nonavigationEndpointper artist — all artists are a single comma-separated string:ParsingHelpers.extractArtists()generates a SHA256 hash ID for these (e.g.,"a1b2c3d4e5f6..."). The oldhasNavigableIdcheck (!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 havehasNav=false, browseId="".Fix
Core/Models/Artist.swifthasNavigableIdnow checksid.hasPrefix("UC")instead of!id.contains("-")Views/macOS/HomeView.swifthasNavigableId+first(where:)(consistent with other views)Views/macOS/SharedViews/FavoritesSection.swifthasNavigableIdCore/Services/ShareService.swiftTests/KasetTests/ModelTests.swiftdocs/common-bug-patterns.mdTesting
swiftlint --strict: 0 violationsswiftformat: 0 files reformatted