feat: expose authentication method on action contexts - #117
Conversation
Greptile SummaryThis PR exposes the Actions API’s
Confidence Score: 4/5The PR is not yet safe to merge because its public The new test establishes that unknown authentication methods are returned as strings, while the current typespec permits only known enum atoms or Files Needing Attention: lib/workos/action_context.ex Important Files Changed
Reviews (2): Last reviewed commit: "fix: document authentication_method as s..." | Re-trigger Greptile |
| @type t :: %__MODULE__{ | ||
| object: String.t() | nil, | ||
| id: String.t() | nil, | ||
| authentication_method: WorkOS.AuthenticateResponseAuthenticationMethod.t() | nil, |
There was a problem hiding this comment.
The reused caster preserves unrecognized authentication methods as raw strings, but this field typespec permits only known enum atoms or nil. This makes the declared contract inaccurate for forward-compatible API values and can mislead static analysis and callers into treating the atom variants as exhaustive.
| authentication_method: WorkOS.AuthenticateResponseAuthenticationMethod.t() | nil, | |
| authentication_method: | |
| WorkOS.AuthenticateResponseAuthenticationMethod.t() | String.t() | nil, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/workos/action_context.ex
Line: 36
Comment:
**Include unknown enum strings**
The reused caster preserves unrecognized authentication methods as raw strings, but this field typespec permits only known enum atoms or `nil`. This makes the declared contract inaccurate for forward-compatible API values and can mislead static analysis and callers into treating the atom variants as exhaustive.
```suggestion
authentication_method:
WorkOS.AuthenticateResponseAuthenticationMethod.t() | String.t() | nil,
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
session restore failed HTTP 422: ENOSPC: no space left on device, write
|
session restore failed HTTP 422: ENOSPC: no space left on device, write |
…aths The ActionContext moduledoc enumerates which fields are common to both context variants, so adding authentication_method left that list understating the shape. This file is hand-maintained precisely because the Actions payload is absent from the OpenAPI spec, making its moduledoc the only documentation of that shape. Route the cast through WorkOS.Cast.enum/2 to match how every other enum field is built (see authenticate_response.ex) and the WorkOS.Cast.nested calls alongside it. Behavior is unchanged; cast/1 already returned nil for nil via its catch-all clause. Both existing payloads gained the field in place, which silently dropped the absent-field coverage they used to provide. Add cases for the nil path and for the lenient caster's unknown-value passthrough, the forward-compatibility behavior that keeps a new server-side method from crashing the SDK. The typespec stays as t() | nil rather than gaining | String.t(): the generated authenticate_response.ex declares the same field the same way with the same lenient caster, and diverging here would make this the only struct in the SDK spelling it differently.
Description
Follow-up to workos/workos#68754. Expose
authentication_methodon the typedActionContextreturned by the Actions helper for authentication and user registration payloads. This reuses the existingWorkOS.AuthenticateResponseAuthenticationMethodenum.Documentation
No SDK documentation changes required. The Actions API documentation is covered by the API change; this PR only makes the existing payload field available through the Elixir helper.
Test plan
mix format lib/workos/action_context.ex test/workos/actions_test.exsmix test test/workos/actions_test.exsRequested by zac.burrage@workos.com via TARS