Repository navigation
fix: leave the audiobook file size out of full-row reads so GET /api/requests stops returning 500 - #609
Merged
Conversation
The Prisma client now omits Audiobook.fileSizeBytes, a BigInt, from every audiobook result, next to the libraryAsin omit. GET /api/requests and the other routes that include the whole audiobook row no longer hand a BigInt to NextResponse.json, so the request list loads when a row holds a file size. GET /api/requests/:id still returns the size for both shapes (non-admin select, admin omit override) through toJsonSafe(). Found and diagnosed by @devinvee in #600. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What changed
Audiobook.fileSizeBytesfrom every audiobook result, next to the existinglibraryAsinomit (src/lib/db.ts). A query that needs the column selects it or setsomit: { fileSizeBytes: false }.GET /api/requests/:idkeeps returningaudiobook.fileSizeBytesfor both shapes: the non-admin field list already selects it, and the admin include now setsomit: { fileSizeBytes: false }. That route already converts BigInt values withtoJsonSafe().tests/services/db-omit-audiobook-columns.test.ts(renamed fromdb-omit-library-asin.test.ts) expects both columns in the client omit and checks that both detail shapes still read the file size; the admin include assertion intests/api/request-display-library-asin.test.tsfollows the new shape.backend/services/api-tokens.md(GET /api/requests/:id returns 500FetchErrorfor any request that has a selected download #261 entry, and the request responses now listaudiobook.fileSizeBytesamong the fields left out) andbackend/database.mdnote the omit.Why
Audiobook.fileSizeBytesis a BigInt.GET /api/requestsincludes the whole audiobook row, so once a row holds a size,NextResponse.jsonthrowsDo not know how to serialize a BigIntand the request list never loads. About nine other routes include the full audiobook row the same way, plus the retry-download job payload. Omitting the column at the client covers all of them in one place. The only reader that wants the value, the request detail route, asks for it explicitly and converts it.#600 proposed wrapping the list response in
toJsonSafe(). With the column omitted that wrap has nothing left to convert (the list rows hold no other BigInt), so this change leaves the route as it is.Checks
npx vitest related --runon the changed source and test files: passing.npx tsc --noEmit: clean.fileSizeBytesuses an explicit select: the request detail query; the only write sets it to null (reported-issue replace). The Library API and the library view loader select their own field lists and never read it.Risk and rollback
Found and diagnosed by @devinvee in #600.
Supersedes #600
🤖 Generated with Claude Code