Repository navigation
fix(lookup): list each online candidate once - #54
Merged
Merged
Conversation
The lookup results crashed with "Key candidate:musicbrainz:<recording>/<release> was already used". MusicBrainz's recording search lists a release once per medium the recording is on: "crossing field (CM SPOT)" is on LiSA's LANDSPACE twice, on the Blu-ray and on the DVD, so the provider built two candidates with the same id and the LazyColumn keyed by it threw while measuring. The provider now keeps one entry per release, the one on the first disc, and LookupService lists each candidate once by provider and id, so no provider can repeat one into the sheet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The crash
Thrown by
SubcomposeLayoutwhile the lookup sheet'sLazyColumnmeasures (LookupSheet.kt, candidates keyed byItemKey.of("candidate", providerId, id)).Root cause
MusicBrainzProvider.toCandidates()builds one candidate per release, with id"$recording/$release". MusicBrainz's recording search lists a release once per medium the recording is on. Checked against the live API for the recording in the report:b5fe1a0e…LANDSPACE (LiSA)b5fe1a0e…LANDSPACE (LiSA)Two candidates, one id, so two items with one key. Any deluxe edition, box set or CD+DVD release with the song on more than one disc triggers it. Nothing between the provider and the list removed repeats.
v2.0.1's
ItemKey.ofstopped different candidates from sharing a key by escaping separators. It could not help here, because these two candidates have the same id.Why Crashlytics mixes albums and candidates
The exception is thrown during layout. No app frame is on the stack, so Crashlytics groups every duplicate-key crash in the app into one issue. Only the message tells them apart:
album:<id>:<Title>: v2.0.0's album keys, fixed in v2.0.1 byf287f63. Album keys are now thegroupBykey itself, so they can't repeat.candidate:musicbrainz:…(ormusicbrainz…without separators in v2.0.0): this bug, present in 2.0.0 and 2.0.1.Filter the issue by version 2.0.1. Every event left should be a
candidate:key.Audit of every data-keyed lazy list
_ID(primary key, one query)ItemKeyof thegroupBykeyNavigation 3 also uses
SaveableStateHolder("Key … was used multiple times").Navigator.goToonly skips a key already on top, so on a wide window the sameEditor(uri)can be on the stack twice. Navigation 3 1.2.0 is built for that (entries with the samecontentKeyshare state, andSceneSetupNavEntryDecoratorrenders each key in one scene only), so it is not a crash source today.The fix
MusicBrainzProvider: one entry per release (distinctBy { it.id }), keeping the lowest disc. This also stops a repeated release from taking one of the three release slots per recording.LookupService: candidates are made distinct by(providerId, id)where every provider's results come together. This is the only way candidates reach the sheet, so no provider can crash the list, Deezer included. Deezer replaces its top hits with/track/{id}details, which could plausibly resolve two hits to one track. That is not verified against the API.Cost: one
distinctByover at most about 35 items per search, once.Tests
MusicBrainzProviderTest: the LANDSPACE response shape gives one candidate per release, from disc 2.LookupTest: a candidate a provider repeats is listed once.Both fail on
master(v2.0.1) and pass with the fix../gradlew test spotlessCheckis green.Not done (options)
#2) in the list. It would stop any future repeat from crashing, but it also hides the data bug. The domain guarantee and its test are the better layer.playstoreflavor, set a Crashlytics custom key with the top destination. Layout crashes would then say where they happened.🤖 Generated with Claude Code