mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[GH-ISSUE #48] OAuth token decoding rejects spec-compliant responses that omit refresh_token or expires_in #5
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-swift-sdk#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mattmillerai on GitHub (Jul 16, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-swift-sdk/issues/48
Split out of the review panel on #44, which flagged both as High/Medium but deferred them: #44 is a no-behavior-change extraction of a shared token-endpoint helper, and both gaps pre-date it (
OAuthExchangerandOAuthTokenRefreshExecutoronmaineach already decoded these as required). Fixing them properly is a breaking public API change, so it gets its own ticket.The gap
OAuthTokenEndpoint.TokenDTOdecodes both fields as required:Neither is required by RFC 6749:
refresh_token(§6) — on a refresh grant the server may omit it, meaning "keep using the one you have." Many providers do not rotate on every refresh. When absent,JSONDecoderthrowskeyNotFound, whichOAuthTokenEndpoint.postwraps asComfyError.unknown. The 401 retry path inTransportonly recovers from.authInvalid/.authExpired, so.unknownescapes: a spec-compliant refresh fails and forces full re-authentication.expires_in(§5.1) — only RECOMMENDED, not required. An omitting server throws during decode and surfaces asComfyError.unknownrather than a usable token.Why it is not a one-line fix
OAuthTokenResponseis a public type (Sources/ComfySwiftSDK/Public/OAuthTokenResponse.swift):So a correct fix has to decide, deliberately:
refresh_token: thread a "reuse the prior refresh token when absent" fallback through the refresh caller and whatever persists the token. The DTO alone cannot do this — only the caller knows the previous token.expires_in: pick a default, and check how it interacts with proactive-refresh scheduling.Option worth considering: keep
OAuthTokenResponsenon-optional (no consumer break), make the DTO fields optional, and haveOAuthTokenEndpoint.posttake the prior refresh token + a default lifetime to fill gaps. That contains the change to internals.Acceptance
refresh_tokensucceeds and retains the previous refresh token.expires_indecodes to a usable token with a documented default.ComfyError.unknown.@coderabbitai[bot] commented on GitHub (Jul 16, 2026):
🔗 Related PRs
Comfy-Org/ComfySwiftSDK#33 - feat(auth): ComfyWebAuthPresenter + one-call ComfyAuth.signIn [merged]
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!