Skip to content

fix: set canonical User-Agent header format#476

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

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

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

Summary

Sets the outgoing User-Agent header to WorkOS; {engine}/{ruby_version}; {platform}; v{VERSION} — the canonical WorkOS Ruby SDK format used through the 6.x line. The 7.0.0 release inadvertently shipped a different shape (workos-ruby/{VERSION} ruby/{ruby_version} ({platform})) that no longer conformed.

The new format also includes the Ruby engine name via RUBY_ENGINE, so traffic from JRuby and TruffleRuby is now distinguishable from MRI in the User-Agent header.

Example UAs:

  • MRI: WorkOS; ruby/3.3.11; arm64-darwin25; v7.1.1
  • JRuby: WorkOS; jruby/9.4.0.0; java; v7.1.1
  • TruffleRuby: WorkOS; truffleruby/24.0.0; arm64-darwin; v7.1.1

Test plan

  • bundle exec rake test (870 runs, 4395 assertions, 0 failures)
  • Confirm User-Agent in a real outgoing request

🤖 Generated with Claude Code

Use the User-Agent format from the 6.x line:
`WorkOS; {engine}/{ruby_version}; {platform}; v{VERSION}`. The
7.0.0 release inadvertently shipped a different shape that no
longer conformed to WorkOS' canonical SDK User-Agent format.

Includes the Ruby engine name (e.g. "ruby", "jruby",
"truffleruby") via RUBY_ENGINE, which the 7.x format dropped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gjtorikian gjtorikian marked this pull request as ready for review May 2, 2026 14:38
@gjtorikian gjtorikian requested review from a team as code owners May 2, 2026 14:38
@gjtorikian gjtorikian requested a review from tribble May 2, 2026 14:38
@gjtorikian gjtorikian merged commit 6728358 into main May 2, 2026
7 checks passed
@gjtorikian gjtorikian deleted the fix/user-agent-format branch May 2, 2026 14:38
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 2, 2026

Greptile Summary

This PR restores the canonical WorkOS Ruby SDK User-Agent format (WorkOS; {engine}/{ruby_version}; {platform}; v{VERSION}) that was inadvertently broken in the 7.0.0 release. It also improves engine visibility by using RUBY_ENGINE so traffic from JRuby and TruffleRuby is distinguishable from MRI.

Confidence Score: 5/5

Safe to merge — single-line constant fix with no behavioural side effects.

Only finding is a P2 style nit (redundant defined? guard). The constant itself is correct, frozen, evaluated at load time, and matches the documented canonical format exactly.

No files require special attention.

Important Files Changed

Filename Overview
lib/workos/base_client.rb Restores canonical WorkOS; {engine}/{ruby_version}; {platform}; v{VERSION} User-Agent format; change is correct and safe.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[BaseClient loads] --> B["Evaluate USER_AGENT constant"]
    B --> C{"RUBY_ENGINE defined?\n(always true in Ruby >= 1.9)"}
    C -->|yes| D["RUBY_ENGINE value\ne.g. ruby / jruby / truffleruby"]
    C -->|no - unreachable| E["fallback: 'ruby'"]
    D --> F["Assemble array\n'WorkOS'\n'{engine}/{RUBY_VERSION}'\nRUBY_PLATFORM\n'v{VERSION}'"]
    E --> F
    F --> G["join('; ').freeze\nWorkOS; ruby/3.3.11; arm64-darwin25; v7.1.1"]
    G --> H["Set as User-Agent on every outgoing HTTP request"]
Loading

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

Comment thread lib/workos/base_client.rb
USER_AGENT = "workos-ruby/#{WorkOS::VERSION} ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM})"
USER_AGENT = [
"WorkOS",
"#{defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"}/#{RUBY_VERSION}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 RUBY_ENGINE guard is redundant in modern Ruby

RUBY_ENGINE has been a built-in constant in every Ruby implementation (MRI, JRuby, TruffleRuby) since Ruby 1.9, so defined?(::RUBY_ENGINE) will always be truthy in any supported version of this gem. The fallback "ruby" string can never be reached. The guard is harmless but adds noise.

Suggested change
"#{defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"}/#{RUBY_VERSION}",
"#{::RUBY_ENGINE}/#{RUBY_VERSION}",

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