Repository navigation
fix: Send the User-Agent header on every request - #112
Merged
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
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.
🔴 Review tier: HIGH — human review required
User-Agent: asknews-sdk-python/<version>(or theuser_agentpassed to the SDK). Until now the SDK sent no User-Agent at all.pytest132 passed (4 new tests, sync and async, respx-mocked);ruff checkclean. Live on dev: asearch_newscall from this branch is metered aschannel=sdk,client=pythononrequests_v4; the same call from the published 1.0.0 is metered as a rawapicall.What
BaseAPIClient.build_api_requestsetsuser-agenton the request it builds (unless the caller passed one). The SDK configures the httpx client with the User-Agent, but it sends hand-builthttpx.Requestobjects throughclient.send(), which does not merge the client's default headers, so the header never left the process.self.user_agentis kept on the client for that.Why
The API gateway now attributes usage to a channel from the User-Agent (
asknews-sdk-python/→ SDK / Python). Without this fix every Python SDK customer shows up as a raw HTTP call. The TS, Go and PHP SDKs already send theirs.