Skip to content

fix: set canonical User-Agent header format#643

Merged
gjtorikian merged 1 commit intomainfrom
fix/user-agent-format
May 1, 2026
Merged

fix: set canonical User-Agent header format#643
gjtorikian merged 1 commit intomainfrom
fix/user-agent-format

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

@gjtorikian gjtorikian commented Apr 30, 2026

Summary

Sets the outgoing User-Agent header to WorkOS 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)
  • Confirm User-Agent in a real outgoing request

🤖 Generated with Claude Code


Open in Devin Review

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>
@gjtorikian gjtorikian marked this pull request as ready for review May 1, 2026 17:28
@gjtorikian gjtorikian requested review from a team as code owners May 1, 2026 17:28
@gjtorikian gjtorikian requested a review from mattgd May 1, 2026 17:28
@gjtorikian gjtorikian merged commit f9cf9a1 into main May 1, 2026
10 of 11 checks passed
@gjtorikian gjtorikian deleted the fix/user-agent-format branch May 1, 2026 17:28
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 1, 2026

Greptile Summary

This PR fixes a regression introduced in 6.0.0 where the outgoing User-Agent header was changed from the canonical WorkOS Python/{python_version} Python SDK/{VERSION} format to workos-python/{VERSION} python/{python_version}. The single-line change in _build_headers restores the original ordering and casing. No logic, security, or compatibility issues were found.

Confidence Score: 5/5

Safe 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

Filename Overview
src/workos/_base_client.py Restores the canonical User-Agent header format to WorkOS Python/{python_version} Python SDK/{VERSION}, reversing the 6.0.0 regression; no logic issues found

Sequence Diagram

sequenceDiagram
    participant Caller
    participant _BaseWorkOSClient
    participant WorkOS API

    Caller->>_BaseWorkOSClient: make request
    _BaseWorkOSClient->>_BaseWorkOSClient: _build_headers()
    Note over _BaseWorkOSClient: User-Agent: WorkOS Python/{python_version} Python SDK/{VERSION}
    _BaseWorkOSClient->>WorkOS API: HTTP request with restored User-Agent header
    WorkOS API-->>_BaseWorkOSClient: response
    _BaseWorkOSClient-->>Caller: parsed result
Loading

Reviews (1): Last reviewed commit: "fix: set canonical User-Agent header for..." | Re-trigger Greptile

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}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

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}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Suggested change
"User-Agent": f"WorkOS Python/{platform.python_version()} Python SDK/{VERSION}",
"User-Agent": f"WorkOS Python SDK/{VERSION} Python/{platform.python_version()}",
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant