Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/workos/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _build_headers(
) -> Dict[str, str]:
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

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.

}
if self._api_key:
headers["Authorization"] = f"Bearer {self._api_key}"
Expand Down
Loading