fix: set canonical User-Agent header format#99
Conversation
The Tesla middleware was sending no `User-Agent` header on
outgoing requests, leaving them indistinguishable from
unrelated traffic. Sets the header to
`workos-elixir/{VERSION}`, matching WorkOS' canonical SDK
User-Agent format.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR adds a Confidence Score: 4/5Safe to merge; only a P2 nil-safety suggestion on the version lookup. The change is small and focused with no logic errors or security concerns. The sole finding is a P2 style suggestion to guard against a nil version string in edge-case environments. No files require special attention. Important Files Changed
|
| end | ||
|
|
||
| defp user_agent do | ||
| "workos-elixir/#{Application.spec(:workos, :vsn)}" |
There was a problem hiding this comment.
Application.spec(:workos, :vsn) returns nil when the application is not loaded (e.g. in certain test setups or as a library dependency that hasn't started). Interpolating nil yields "workos-elixir/", which is a malformed User-Agent. A compile-time attribute or a runtime fallback would be safer.
| "workos-elixir/#{Application.spec(:workos, :vsn)}" | |
| version = Application.spec(:workos, :vsn) || "unknown" | |
| "workos-elixir/#{version}" |
Summary
The Tesla middleware was sending no
User-Agentheader on outgoing requests. This adds one in the canonical WorkOS SDK format:workos-elixir/{VERSION}, with the version pulled from the application spec.Test plan
Application.spec(:workos, :vsn)returns the charlist version (e.g.~c"1.2.1"), and Elixir'sString.Chars.Listimplementation converts charlists to a binary on#{}interpolation, so the resulting header value isworkos-elixir/1.2.1.🤖 Generated with Claude Code