test(api): cover the transport-error path (HTTP.Do failure)#255
Merged
Conversation
The api transport-error harness from the coverage audit — an errRoundTripper that fails every request, simulating the most common real-world API failure the httptest-server tests can't reach (connection refused / DNS / reset, i.e. HTTP.Do itself erroring). Previously untested in get / bodyRequest. - get wraps the transport error (errors.Is). - bodyRequest surfaces it. - an exported call (WhoAmI) fails on a dead transport rather than reading a zero-value identity as success. make ci green. No production changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f1b129d. Configure here.
saadqbal
approved these changes
Jul 14, 2026
saadqbal
left a comment
Collaborator
There was a problem hiding this comment.
LGTM 👍 The errRoundTripper is the right way to hit the HTTP.Do failure branch the httptest tests can't reach, and get/bodyRequest both wrap with %w so the errors.Is check holds through the url.Error layer.
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.
The api transport-error harness from the coverage audit — an
errRoundTripperthat fails every request, simulating the most common real-world API failure the httptest tests can't reach (connection refused / DNS / reset, i.e.HTTP.Doitself erroring). Previously untested inget/bodyRequest.getwraps the transport error (errors.Is).bodyRequestsurfaces it.WhoAmI) fails on a dead transport rather than reading a zero-value identity as success.make cigreen. No production changes.🤖 Generated with Claude Code
Note
Low Risk
Test-only addition with no runtime or production behavior changes.
Overview
Adds
internal/api/transport_test.gowith anerrRoundTripperstub so tests can forceHTTP.Doto fail (connection refused / DNS / reset) without a real server—paths thathttptest-based tests do not cover.TestTransportErrorasserts thatgetwraps the transport error (checkable viaerrors.Is),bodyRequestreturns an error, andWhoAmIfails instead of treating a zeroIdentityas success when the transport is down.No production code changes.
Reviewed by Cursor Bugbot for commit f1b129d. Bugbot is set up for automated code reviews on this repo. Configure here.