fix: set canonical User-Agent header format#643
Conversation
Use the User-Agent format from the 5.x line:
`WorkOS Python/{python_version} Python SDK/{VERSION}`. The 6.0.0
release inadvertently shipped a different shape that no longer
conformed to WorkOS' canonical SDK User-Agent format.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes a regression introduced in 6.0.0 where the outgoing Confidence Score: 5/5Safe to merge — minimal, targeted one-line fix with no functional side effects Single-line header string change that restores a documented canonical format; no security, logic, or compatibility issues present. The only finding is a P2 suggestion to add a regression test. No files require special attention Important Files Changed
|
| headers: Dict[str, str] = { | ||
| "Content-Type": "application/json", | ||
| "User-Agent": f"workos-python/{VERSION} python/{platform.python_version()}", | ||
| "User-Agent": f"WorkOS Python/{platform.python_version()} Python SDK/{VERSION}", |
There was a problem hiding this comment.
No test coverage for User-Agent header format
The existing test suite has no assertion that verifies the exact string set in the User-Agent header. Since this PR was created specifically to restore a previously-broken header value, a dedicated test would prevent the same regression from silently reappearing in a future refactor of _build_headers.
| headers: Dict[str, str] = { | ||
| "Content-Type": "application/json", | ||
| "User-Agent": f"workos-python/{VERSION} python/{platform.python_version()}", | ||
| "User-Agent": f"WorkOS Python/{platform.python_version()} Python SDK/{VERSION}", |
There was a problem hiding this comment.
🔴 User-Agent header has SDK version and Python runtime version swapped
The new User-Agent string WorkOS Python/{platform.python_version()} Python SDK/{VERSION} pairs the wrong version with each product token. Per the product/version User-Agent convention (RFC 7231), this produces e.g. WorkOS Python/3.10.12 Python SDK/6.1.0, which incorrectly claims the "WorkOS Python" product is version 3.10.12 (actually the Python runtime version) and "Python SDK" is version 6.1.0 (actually the WorkOS SDK version). The old format workos-python/{VERSION} python/{platform.python_version()} had the versions correctly associated. Server-side analytics or request routing that parses User-Agent strings will misidentify the SDK version.
| "User-Agent": f"WorkOS Python/{platform.python_version()} Python SDK/{VERSION}", | |
| "User-Agent": f"WorkOS Python SDK/{VERSION} Python/{platform.python_version()}", |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Sets the outgoing
User-Agentheader toWorkOS Python/{python_version} Python SDK/{VERSION}— the canonical WorkOS Python SDK format used through the 5.x line. The 6.0.0 release inadvertently shipped a different shape (workos-python/{VERSION} python/{python_version}) that no longer conformed.Same data, restored ordering.
Test plan
uv run pytest tests/(1987 passed)🤖 Generated with Claude Code