Skip to content

v0.1.12: not-found ctx.fail routing, getAuthorWorks 404 detection

Choose a tag to compare

@cyanheads cyanheads released this 04 Jun 08:16
v0.1.12
1c027e8

not-found ctx.fail routing, getAuthorWorks 404 detection

Service methods (getWork, getAuthor, getEditions, getSubject, getAuthorWorks) now return null on not-found instead of throwing notFound() directly. Handlers route the null return through ctx.fail('not_found', ...) so data.reason is populated on the wire and the typed error contracts are exercised.

Fixed:

  • getAuthorWorks: Open Library returns HTTP 404 + {} for non-existent author IDs; the empty-object response was silently treated as valid (total: undefined, works: []). Guard added to detect and return null. (#5)
  • getWork, getAuthor, getEditions, getSubject: notFound() moved from service layer to handler ctx.fail so data.reason is set. (#6)
  • openlibraryAuthorResource, openlibraryWorkResource: same null-guard + notFound() pattern.
  • Tests updated and new edge-case tests added for all affected tools and resources.

193 tests pass; bun run devcheck clean.