fix: set default User-Agent on OpenAI driver HTTP client#433
Open
ozekimasaki wants to merge 1 commit intoRightNow-AI:mainfrom
Open
fix: set default User-Agent on OpenAI driver HTTP client#433ozekimasaki wants to merge 1 commit intoRightNow-AI:mainfrom
ozekimasaki wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
reqwest::Client::new() sends no User-Agent header by default. Some OpenAI-compatible API providers and proxies reject requests that lack a User-Agent, returning 405 errors. This sets "OpenFang/1.0" as a sensible default with a graceful fallback if the builder fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The openai adapter already has a with_extra_headers method, it's just not being called during registration. Wouldn't it be more elegant if your PR supported passing the User-Agent via configuration instead? |
Author
|
Thanks for the feedback! I considered that, but I think a sensible default User-Agent belongs at the client level rather than in configuration:
The two aren't mutually exclusive — users can still override User-Agent via |
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
reqwest::Client::new()does not set aUser-Agentheader by defaultUser-Agent, returning 405 errorsOpenFang/1.0as a sensible default, with a graceful fallback toreqwest::Client::new()if the builder failsChanges
File:
crates/openfang-runtime/src/drivers/openai.rs(1 file, +4 −1)Test plan