Skip to content

Mark client-generated results as synthetic - #211

Merged
edridudi merged 1 commit into
mainfrom
claude/synthetic-status-codes
Sep 12, 2026
Merged

edridudi merged 1 commit into
mainfrom
claude/synthetic-status-codes

Conversation

@edridudi

Copy link
Copy Markdown
Collaborator

Step 3 of #6.

The client returns a failed Result in three cases where no HTTP error occurred at all:

Where Situation Code returned
processResponseGetOne 200 with an empty body 404
processResponseGetOne 200 with a null body 500
badRequestResult rejected by local validation, never sent 400

Those are indistinguishable from the same codes reported by Koios. A caller branching on getCode() cannot tell a real 404 from "the list came back empty", nor a real 400 from 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:

  • real server 400 with a PostgREST body → synthetic == false
  • real server 500 → synthetic == false
  • 200 with [] → code 404, synthetic == true
  • getAssetInformationBulk(null, ...) → code 400, synthetic == true, and server.getRequestCount() == 0 proving nothing was sent
mvn test -Dtest='*Preview*,BaseServiceErrorHandlingTest,ProposalDeserializationTest,*Bech32*'   # 142/142 pass
mvn verify -DskipTests                                                                          # javadoc clean

🤖 Generated with Claude Code

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>
@edridudi
edridudi merged commit ed2dce7 into main Sep 12, 2026
3 checks passed
@edridudi
edridudi deleted the claude/synthetic-status-codes branch September 12, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant