fix: handle BigInt serialization in REST API v1 detail endpoints#53
Merged
TerrifiedBug merged 1 commit intomainfrom Mar 7, 2026
Merged
fix: handle BigInt serialization in REST API v1 detail endpoints#53TerrifiedBug merged 1 commit intomainfrom
TerrifiedBug merged 1 commit intomainfrom
Conversation
GET /api/v1/pipelines/:id and /api/v1/nodes/:id return 500 because NodePipelineStatus contains BigInt fields (eventsIn, eventsOut, etc.) that JSON.stringify cannot serialize. Adds a jsonResponse() helper using a custom replacer to convert BigInts to numbers.
Contributor
Greptile SummaryThis PR fixes a real HTTP 500 bug on Changes:
The implementation correctly addresses the root cause with minimal surface area. All error paths remain untouched, and existing auth/permission middleware is preserved. Confidence Score: 5/5
Sequence DiagramsequenceDiagram
participant C as API Client
participant R as Route Handler
participant P as Prisma (PostgreSQL)
participant J as jsonResponse()
C->>R: GET /api/v1/pipelines/:id (or /nodes/:id)
R->>R: authenticateApiKey() + hasPermission()
R->>P: findUnique({ select: { nodeStatuses: { eventsIn, eventsOut, errorsTotal } } })
P-->>R: Record with BigInt fields (e.g. eventsIn: 42n)
R->>J: jsonResponse({ pipeline })
J->>J: JSON.stringify(data, BigInt → Number replacer)
J-->>C: 200 OK, Content-Type: application/json<br/>{ "pipeline": { "nodeStatuses": [{ "eventsIn": 42 }] } }
Last reviewed commit: 1a0f5e6 |
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.
Summary
GET /api/v1/pipelines/:idandGET /api/v1/nodes/:idreturn HTTP 500 becauseNodePipelineStatuscontains BigInt fields (eventsIn,eventsOut,errorsTotal, etc.) thatJSON.stringify()cannot serializejsonResponse()helper inapi-handler.tsthat uses a custom JSON replacer to convert BigInts to numbersjsonResponse()instead ofNextResponse.json()Test plan
GET /api/v1/pipelines/:idreturns 200 with pipeline detail including nodeStatusesGET /api/v1/nodes/:idreturns 200 with node detail including pipelineStatuses