-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: improve OpenAI-compatible error handling and add test coverage #4175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Collaborator
|
thanks Adrian tagging @DOsinga as I know he had designs on making openai and providers more declarative and configurable will need a good old cargo fmt run of course |
DOsinga
approved these changes
Aug 19, 2025
Improves error handling reliability for OpenAI-compatible providers and adds comprehensive test coverage.
I tried using Goose through a gateway which had an incorrect max payload size. The gateway returned a plain text error.
Before, the underlying error was obfuscated by a JSON failure:
`Error: Request failed: error decoding response body`
```bash
$ goose run --debug -t 'should I install goose?'
starting session | provider: openai model: qwen3
logging to /Users/codefromthecrypt/.local/share/goose/sessions/20250819_090611.jsonl
working directory: /Users/codefromthecrypt/oss/goose
Error: Request failed: error decoding response body
Interrupted before the model replied and removed the last message.
error: The error above was an exception we were not able to handle.
These errors are often related to connection or authentication
We've removed the conversation up to the most recent user message
- depending on the error you may be able to continue
```
Now, the error is easier to see:
`Error: Request failed: Request failed with status: 413 Payload Too Large`
```bash
$ ./target/debug/goose run --debug -t 'should I install goose?'
starting session | provider: openai model: qwen3
logging to /Users/codefromthecrypt/.local/share/goose/sessions/20250819_090540.jsonl
working directory: /Users/codefromthecrypt/oss/goose
2025-08-19T02:05:53.160383Z WARN goose::providers::utils: Provider request failed with status: 413 Payload Too Large. Payload: None. Returning error: RequestFailed("Request failed with status: 413 Payload Too Large")
at crates/goose/src/providers/utils.rs:113
Error: Request failed: Request failed with status: 413 Payload Too Large
Interrupted before the model replied and removed the last message.
error: The error above was an exception we were not able to handle.
These errors are often related to connection or authentication
We've removed the conversation up to the most recent user message
- depending on the error you may be able to continue
```
**Changes:**
- Add `PartialEq` derive to `ProviderError` enum to enable testing
- Refactor `handle_status_openai_compat` to improve error parsing and reduce complexity
- Enhance authentication error message formatting with cleaner conditional logic
- Add comprehensive test suite covering various error scenarios and edge cases
- Improve function documentation with clear references to OpenAI error codes
**Impact:**
- More reliable error handling when provider APIs return malformed responses
- Better error messages for authentication failures
- Increased test coverage prevents regressions in error handling logic
- Cleaner code structure improves maintainability
Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Adrian Cole <[email protected]>
5c17351 to
f7cb5fc
Compare
Collaborator
Author
|
rebased! |
Collaborator
|
running now... |
michaelneale
approved these changes
Aug 20, 2025
jamadeo
reviewed
Aug 20, 2025
Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Adrian Cole <[email protected]>
Collaborator
|
get it in when the lights are green! |
Collaborator
Author
|
I see 💚 |
michaelneale
added a commit
that referenced
this pull request
Aug 24, 2025
* main: docs: Plan tutorial (#4309) Extensions Modal Improvements (#4293) docs: fixed cicd tutorial pipeline in docs (#4223) Read oltp config from config and env (#4292) release/1.6.0 (#4280) docs: fix broken links in Docker tutorial (#4285) Remove half-second wait, rework auto submit (#4282) Block send until extensions are ready (#4271) fix: improve OpenAI-compatible error handling and add test coverage (#4175) Move To-Do Tool to Session Scope from Agent Scope (#4157) fix: recipe params not being replaced all the time (#4207) chore: removing little-used session sharing feature (#4249) Stop auto scrolling when agent responds and let scroll area handle scrolling to bottom (#4257) restore cli projects from accidental removal during cleanup (#4266) Fix: deep link extension installation to show dialog for headers configuration (#4150)
michaelneale
added a commit
that referenced
this pull request
Aug 25, 2025
* main: (24 commits) feat: autovisualiser of structured data with mcp-ui (#4153) docs: Plan tutorial (#4309) Extensions Modal Improvements (#4293) docs: fixed cicd tutorial pipeline in docs (#4223) Read oltp config from config and env (#4292) release/1.6.0 (#4280) docs: fix broken links in Docker tutorial (#4285) Remove half-second wait, rework auto submit (#4282) Block send until extensions are ready (#4271) fix: improve OpenAI-compatible error handling and add test coverage (#4175) Move To-Do Tool to Session Scope from Agent Scope (#4157) fix: recipe params not being replaced all the time (#4207) chore: removing little-used session sharing feature (#4249) Stop auto scrolling when agent responds and let scroll area handle scrolling to bottom (#4257) restore cli projects from accidental removal during cleanup (#4266) Fix: deep link extension installation to show dialog for headers configuration (#4150) feat: Add message queue system with interruption handling (#4179) Start extensions concurrently (#4234) Add X-Title and referer headers on exchange to tetrate (#4250) docs: update View/Edit Recipe menu item name (#4267) ...
shellz-n-stuff
pushed a commit
to shellz-n-stuff/goose
that referenced
this pull request
Aug 27, 2025
…lock#4175) Signed-off-by: Adrian Cole <[email protected]> Signed-off-by: Alex Rosenzweig <[email protected]>
This was referenced Aug 27, 2025
dorien-koelemeijer
pushed a commit
to dorien-koelemeijer/goose
that referenced
this pull request
Sep 2, 2025
…lock#4175) Signed-off-by: Adrian Cole <[email protected]> Signed-off-by: Dorien Koelemeijer <[email protected]>
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.
Improves error handling reliability for OpenAI-compatible providers and adds comprehensive test coverage.
I tried using Goose through a gateway which had an incorrect max payload size. The gateway returned a plain text error.
Before, the underlying error was obfuscated by a JSON failure:
Error: Request failed: error decoding response bodyNow, the error is easier to see:
Error: Request failed: Request failed with status: 413 Payload Too LargeChanges:
PartialEqderive toProviderErrorenum to enable testinghandle_status_openai_compatto improve error parsing and reduce complexityImpact: