Skip to content

fix: set canonical User-Agent header format#1576

Open
gjtorikian wants to merge 1 commit intomainfrom
fix/user-agent-format
Open

fix: set canonical User-Agent header format#1576
gjtorikian wants to merge 1 commit intomainfrom
fix/user-agent-format

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

@gjtorikian gjtorikian commented Apr 30, 2026

Summary

The outgoing User-Agent header is now always workos-node/{VERSION} — the canonical WorkOS Node SDK format used through the 6.x line. The 7.x and 8.x lines accumulated several augmentations that no longer conformed (/fetch HTTP-client annotation, (node/v22.0.0) runtime info, appName: appVer from appInfo).

Behavior changes

  • Runtime detection is no longer appended to the header.
  • appInfo option still parses for backwards compatibility, but the value no longer affects the User-Agent header.
  • The addClientToUserAgent helper now returns the input unchanged.

Callers relying on these tokens being present in User-Agent will need to set a separate header via the request-options headers mechanism.

Test plan

  • npx jest (683 passed, 0 failed)
  • Confirm User-Agent: workos-node/{VERSION} on a real outgoing request

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Simplified User-Agent header generation to improve consistency and compatibility.
  • Tests

    • Updated User-Agent header assertions to reflect streamlined header format.

The User-Agent header is now always `workos-node/{VERSION}`,
matching the canonical WorkOS Node SDK format used through the
6.x line.

Three pieces of behavior added in later majors that broke
conformance are removed:

- Runtime detection no longer appended (e.g. `(node/v22.0.0)`)
- The `appInfo` option is still accepted for backwards
  compatibility, but the value no longer affects the outgoing
  User-Agent header
- The HTTP-client annotation injected by `addClientToUserAgent`
  (e.g. `/fetch`) is dropped

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2b43332e-f21f-474d-8c52-e467a562a0f3

📥 Commits

Reviewing files that changed from the base of the PR and between c4793bc and 983e8fc.

📒 Files selected for processing (4)
  • src/common/net/http-client.ts
  • src/sso/sso.spec.ts
  • src/workos.spec.ts
  • src/workos.ts

📝 Walkthrough

Walkthrough

User-Agent header generation is simplified across the SDK. The implementation no longer appends runtime version information or app info details, reducing the User-Agent to a basic workos-node/<version> format. Corresponding test expectations are updated to match the simplified format.

Changes

Cohort / File(s) Summary
Core User-Agent Generation
src/workos.ts, src/common/net/http-client.ts
User-Agent generation logic simplified to return only workos-node/<version> without runtime/fetch information or appInfo fields. getRuntimeInfo import removed and addClientToUserAgent now returns input unchanged.
Test Assertions
src/sso/sso.spec.ts, src/workos.spec.ts
User-Agent header regex expectations relaxed to match only workos-node/<version> pattern instead of additionally requiring the "/fetch (node/v...)" segment.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description provides clear context about behavior changes, but does not complete the required template section about documentation updates. Complete the documentation template by marking the checkbox and confirming whether WorkOS Docs changes are needed for this User-Agent format change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: standardizing the User-Agent header format to a canonical format.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/user-agent-format

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@gjtorikian gjtorikian marked this pull request as ready for review May 1, 2026 19:46
@gjtorikian gjtorikian requested review from a team as code owners May 1, 2026 19:46
@gjtorikian gjtorikian requested a review from dandorman May 1, 2026 19:46
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 1, 2026

Greptile Summary

This PR strips the User-Agent header back to the canonical workos-node/{VERSION} format by removing runtime-info detection ((node/vX.Y.Z)) and appInfo augmentation. The addClientToUserAgent helper is reduced to a passthrough and all affected tests are updated to match.

Confidence Score: 4/5

Safe to merge — the behaviour change is intentional and tests pass; only minor cleanup remains.

Only P2 findings: one stale test description and dead getClientName code. No logic errors or security concerns.

src/common/net/http-client.ts — getClientName and its interface/subclass implementations are now unreachable dead code.

Important Files Changed

Filename Overview
src/workos.ts Removed runtime-info and appInfo augmentation from createUserAgent; now returns a fixed workos-node/{VERSION} string. _options parameter is intentionally unused.
src/common/net/http-client.ts Simplified addClientToUserAgent to be a no-op passthrough; getClientName() is now dead code but left in place.
src/workos.spec.ts Regex patterns updated to match the new simpler format; one test description ('adds the HTTP client name to the user-agent') is now stale and misleading.
src/sso/sso.spec.ts User-Agent regex expectations updated to the new canonical format; no issues found.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[WorkOS constructor] --> B[createUserAgent]
    B --> C["return 'workos-node/VERSION'"]
    C --> D[createHttpClient sets User-Agent header]
    D --> E[FetchHttpClient stores header in options]
    E --> F[fetchRequest extracts User-Agent from options]
    F --> G[addClientToUserAgent called]
    G --> H["returns userAgent unchanged (no-op)"]
    H --> I[User-Agent set on outgoing request]
    style G fill:#f9f,stroke:#333
    style H fill:#f9f,stroke:#333
Loading

Comments Outside Diff (2)

  1. src/workos.spec.ts, line 174 (link)

    P2 Stale test description

    The test description 'adds the HTTP client name to the user-agent' no longer reflects the implemented behavior — the HTTP client name is explicitly not appended anymore. This will mislead anyone reading the test.

  2. src/common/net/http-client.ts, line 22-23 (link)

    P2 getClientName is now dead code

    addClientToUserAgent used to call this.getClientName() to build the augmented header; now it returns its input unchanged. getClientName() is still declared in HttpClientInterface, implemented as a throwing stub in HttpClient, and overridden in FetchHttpClient (returning 'fetch'), but it is never invoked anywhere. Consider removing it from the interface, the base class, and FetchHttpClient to avoid carrying dead code forward.

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

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