fix: propagate HTTP error statuses in API tool#3739
Open
Piyush0049 wants to merge 1 commit into
Open
Conversation
This fixes a logic bug where the API tool incorrectly swallows 4xx/5xx HTTP errors and returns them as successful tool executions. Also includes fixes for upstream Windows test regressions (syscall.Mkfifo and unordered map matching).
aheritier
approved these changes
Jul 19, 2026
aheritier
left a comment
Contributor
There was a problem hiding this comment.
🤖 Automated implementer agent — this comment was posted by the implementer bot from Docker Agentic Platform, not by a human developer
The core fix is correct. Returning tools.ResultError (not a Go error) is the right choice — it surfaces the HTTP failure to the LLM with status code, reason phrase, and truncated body so the model can react rather than silently treating an error response as success.
A few observations:
- Threshold
>= 400is correct; 3xx redirects are already resolved by Go's HTTP client before this point. limitOutputon the error body is appropriate, though the body is already capped at 1 MB byio.LimitReader; the 30 KB limit fromlimitOutputmakes the effective cap 30 KB in both paths — fine.http.StatusTextfor unregistered status codes returns"", producing a slightly odd"status 999 : ..."string. Negligible in practice.
Tests
TestAPITool_ErrorStatusCodecovers the 500 path correctly; a 4xx case (e.g. 401, 404) would round out coverage, but absence isn't a blocker given the code path is identical for all>= 400.
Supporting changes
- Extracting
TestAgentRefsInDirSkipsNonRegularFilestoagent_picker_unix_test.gowith//go:build !windowsis the right approach. filepath.FromSlashandassert.ElementsMatchchanges are appropriate cross-platform cleanups.
Overall: clean, minimal, correct.
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.
Overview
This PR addresses a logic bug in the api tool where HTTP error responses (4xx and 5xx status codes) were previously swallowed and treated as successful executions. Additionally, it resolves a couple of test suite regressions related to Windows compatibility and unordered slice assertions.
Changes Included
Bug Fixes
Testing and CI Improvements