fix: append /chat/completions for prefixed v1 base URLs#8521
Open
aravind4219 wants to merge 3 commits intoaaif-goose:mainfrom
Open
fix: append /chat/completions for prefixed v1 base URLs#8521aravind4219 wants to merge 3 commits intoaaif-goose:mainfrom
aravind4219 wants to merge 3 commits intoaaif-goose:mainfrom
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
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.
Summary
Fixed a bug where custom OpenAI-compatible providers with a prefixed base_url like https://opencode.ai/zen/go/v1 would fail with a 404 because goose was hitting …/zen/go/v1 directly instead of …/zen/go/v1/chat/completions.
The path detection logic in from_custom_config knew to append /chat/completions when the URL path was exactly /v1, but didn't handle the case where /v1 came after a custom prefix. One line of logic, but easy to miss when you're configuring a provider that doesn't follow the standard api.example.com/v1 pattern.
Testing
Added 7 unit tests for the new derive_base_path helper covering the broken case and making sure existing patterns (bare /v1, already-full endpoint paths, non-v1 custom paths) still work correctly. All existing tests pass.
Related Issues
Relates to #ISSUE_ID : 8517
Discussion: LINK (if any): #8517