fix(metadata): stop rendering Audible's not-found stub as a book - #43
Merged
Conversation
Looking a book up by ASIN showed "Unknown Title" for anything Audible has
no product for. Audible answers 200 with a stub rather than 404 —
{"asin":…,"asset_details":[],"is_vvab":false} under an "always-returned"
response group — and the mapper accepted it because it required only an
ASIN. That produced a book with every other field empty, which the
lookup UI rendered as "Unknown Title".
MetadataController already turns a null result into a 404, and the UI
already has a "No audiobook was found with ASIN" message for it; neither
ever fired because the result was never null. Requiring a title in the
mapper makes both work as intended. A real product always carries one.
The same mapper feeds the monitored-series catalogue, so a stub in a
series' relationships array would have added a titleless phantom book to
the library. This closes that too.
Log a warning when a document maps to nothing, because the stub cannot be
told apart from Audible refusing to answer properly for a given host — if
every lookup logs this, the ASINs are fine and the catalog API is not.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YCsUgtQ6zHRVnRAnWjjryc
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.
Looking a book up by ASIN showed "Unknown Title" for anything Audible has no product for.
Cause
Audible's catalogue API answers 200 with a stub rather than 404 for an unknown ASIN:
{"product":{"asin":"B0DFKPXBWQ","asset_details":[],"is_vvab":false}, "response_groups":["always-returned"]}AudibleProductMapper.MapProductToBookResponserequired only an ASIN, so it mapped that stub into a "book" with every other field empty. The API returned it as a 200 and the UI renderedresult.title || 'Unknown Title'.MetadataControlleralready turns a null result into a 404, anduseSearchalready has a "No audiobook was found with ASIN …" message for it. Neither ever fired, because the result was never null.Fix
Require a non-blank title in the mapper. A real Audible product always has one, so its absence is the signal that nothing came back. All three call sites — single lookup, batch lookup and product search — only checked
Asin, so fixing the one choke point fixes them all.The same mapper feeds the monitored-series catalogue via
GetBooksMetadataByAsinsAsync, so a stub in a series'relationshipsarray would have added a titleless phantom book to the library. This closes that too.It also logs a warning when a document maps to nothing. The stub is indistinguishable from Audible declining to answer properly for a particular host, so if every lookup logs this, the ASINs are fine and the catalog API is the problem — which is worth being able to see from the logs.
Verified against the running API
Before:
After:
Testing
AudibleProductMapperStubTestscovers the stub captured verbatim from the live API, blank and whitespace titles, the unchanged missing-ASIN guard, a non-object document, and a real product mapping through untouched.dotnet formatclean; the Metadata, Search, Monitoring, Catalog and architecture suites show the same 46 failures as canary, compared by stashing and re-running rather than assumed.vue-tscpass.Scope note
If ASIN lookups are failing for every ASIN on a particular deployment, this change turns "Unknown Title" into an honest "not found" and puts a warning in the log, but the underlying cause would be that host's access to
api.audible.com— worth checking with a directcurlfrom that machine.🤖 Generated with Claude Code
https://claude.ai/code/session_01YCsUgtQ6zHRVnRAnWjjryc