Repository navigation
Mark client-generated results as synthetic - #211
Merged
Merged
Conversation
Step 3 of #6. The client returns a failed Result in three cases where no HTTP error occurred: processResponseGetOne 200 with an empty body -> code 404 processResponseGetOne 200 with a null body -> code 500 badRequestResult rejected before sending -> code 400 Those codes were indistinguishable from the same codes reported by Koios, so a caller branching on getCode() could not tell a real 404 from "the list came back empty", nor a real 400 from a request that never left the client. Adds Result.synthetic, true for exactly those three cases and false for every result reflecting an actual HTTP response. The codes themselves are unchanged, so existing callers keep working; the flag is there for callers that need the distinction. Co-Authored-By: Claude Opus 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.
Step 3 of #6.
The client returns a failed
Resultin three cases where no HTTP error occurred at all:processResponseGetOne404processResponseGetOne500badRequestResult400Those are indistinguishable from the same codes reported by Koios. A caller branching on
getCode()cannot tell a real404from "the list came back empty", nor a real400from a request that never left the client — and in the empty-body case the server actually returned 200.Change
Adds
Result.synthetic: true for exactly those three cases, false for every result that reflects an actual HTTP response, successful or not.The codes themselves are unchanged, so existing callers keep working. This is the non-breaking half of the fix — the flag lets callers that need the distinction ask for it, without silently changing what anyone already matches on. Option B, dropping the invented codes entirely, is more honest but breaks anyone relying on the current behaviour; worth revisiting at a major version.
Testing
Four assertions across the MockWebServer suite, covering both directions:
400with a PostgREST body →synthetic == false500→synthetic == false[]→ code404,synthetic == truegetAssetInformationBulk(null, ...)→ code400,synthetic == true, andserver.getRequestCount() == 0proving nothing was sent🤖 Generated with Claude Code