Pre-flight
Problem
The direct AddBook path can hydrate Hardcover editions after a successful direct insert only when the fetched book already has a confident Hardcover identity, such as an hc: foreign ID or populated HardcoverForeignID.
When the direct-fetched book is an OpenLibrary row with no matched Hardcover identity, the existing hydration helper intentionally no-ops. That leaves audiobook-specific enrichment, edition rows, and possible ASIN promotion missing even when Hardcover has a matching record.
A real example is adding an audiobook-first OpenLibrary result such as Twilight: the book can be inserted from OpenLibrary, but without a matched Hardcover ID the direct hydration path cannot fetch Hardcover editions.
Proposed solution
Add a narrow matching step for direct AddBook inserts when enhanced Hardcover is enabled and the direct-fetched book lacks a Hardcover identity.
Expected behavior:
- Keep the stored book identity as the selected primary provider result, e.g. OpenLibrary.
- Find a confident Hardcover equivalent using existing metadata matching concepts where possible, preferably the same author-work merge logic that can populate
HardcoverForeignID during author catalog sync.
- If a confident Hardcover match is found, call the existing Hardcover edition hydration flow with that matched
hc: ID.
- If no confident match is found, keep the current no-op behavior and do not block the add request.
Alternatives considered
- Require users to manually rebind/map the book to Hardcover. This works but is extra friction for a path that already has enough metadata in many cases.
- Change the stored book identity to Hardcover during direct add. That is broader and would alter provider identity semantics; the smaller behavior is to preserve the selected identity and use Hardcover only for supplemental edition hydration.
Additional context
This is a follow-up to the direct AddBook hydration fix in internal/api/authors.go, where direct-created books now call the existing hydration helper after a successful create. That fix intentionally remains a no-op when the book has no hc: identity or HardcoverForeignID; this issue tracks the separate matching enhancement.
Pre-flight
Problem
The direct AddBook path can hydrate Hardcover editions after a successful direct insert only when the fetched book already has a confident Hardcover identity, such as an
hc:foreign ID or populatedHardcoverForeignID.When the direct-fetched book is an OpenLibrary row with no matched Hardcover identity, the existing hydration helper intentionally no-ops. That leaves audiobook-specific enrichment, edition rows, and possible ASIN promotion missing even when Hardcover has a matching record.
A real example is adding an audiobook-first OpenLibrary result such as
Twilight: the book can be inserted from OpenLibrary, but without a matched Hardcover ID the direct hydration path cannot fetch Hardcover editions.Proposed solution
Add a narrow matching step for direct AddBook inserts when enhanced Hardcover is enabled and the direct-fetched book lacks a Hardcover identity.
Expected behavior:
HardcoverForeignIDduring author catalog sync.hc:ID.Alternatives considered
Additional context
This is a follow-up to the direct AddBook hydration fix in
internal/api/authors.go, where direct-created books now call the existing hydration helper after a successful create. That fix intentionally remains a no-op when the book has nohc:identity orHardcoverForeignID; this issue tracks the separate matching enhancement.