Skip to content

fix(search): unwrap bare-array response in searchAudibleByTitleAndAuthor#749

Draft
kevinheneveld wants to merge 1 commit into
Listenarrs:canaryfrom
kevinheneveld:fix/audible-search-array-response
Draft

fix(search): unwrap bare-array response in searchAudibleByTitleAndAuthor#749
kevinheneveld wants to merge 1 commit into
Listenarrs:canaryfrom
kevinheneveld:fix/audible-search-array-response

Conversation

@kevinheneveld

Copy link
Copy Markdown
Contributor

Summary

  • POST /search in Advanced mode returns a bare JSON array, not {results, totalResults}
  • searchAudibleByTitleAndAuthor only ever read response.results, which doesn't exist on a plain array, so it silently discarded every result and always reported empty — confirmed live against a real Audible title/author search where the backend genuinely found the match
  • The other two frontend callers of this same endpoint (getAuthorLookup, advancedSearch) already defensively handle both shapes (Array.isArray(resp) ? resp : (resp?.results ?? [])); this one never did

Test plan

  • vue-tsc --build — clean
  • vite build — clean
  • vitest run — 394/394 passing (2 new regression tests: bare-array shape + object-wrapped shape)

Draft per PR-pacing convention (several PRs already active); will promote when a slot frees up.

The Advanced-mode branch of POST /search returns a bare JSON array,
not {results, totalResults} — confirmed live against a real Audible
title/author search: the backend genuinely found the book, but the UI
still reported "no matches in any region", because this function only
ever read response.results, which doesn't exist on a plain array.

The other two frontend callers of this same endpoint
(getAuthorLookup, advancedSearch) already defensively handle both
response shapes; this one never did, so every search through it
silently discarded whatever the backend found and always fell through
to the empty-results path, regardless of query quality.
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.

1 participant