[codex] Structure OAuth scope encoding failures#3368
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This change replaces a generic Error with a structured OAuthScopeEncodingError class that provides detailed information about encoding failures. The validation logic and error scenarios remain the same - this is a low-risk improvement to error handling with accompanying tests. You can customize Macroscope's approvability policy. Learn more. |
Summary
Validation
pnpm vp test packages/shared/src/oauthScope.test.tspnpm vp check(passes with 20 existing warnings)pnpm vp run typecheckOverlap
--limit 1000) found no overlapNote
Low Risk
Localized validation and error-shape change in shared OAuth scope helpers; successful encoding behavior is unchanged for valid inputs.
Overview
encodeOAuthScopeno longer round-trips throughparseOAuthScopeand a genericError. It validates each scope token directly and throws a schema-backedOAuthScopeEncodingErrorthat carries the originalscopes,invalidScopes, andduplicateScopes, with the same generic user-facing message.This closes a validation gap where an invalid scope containing a space could be accepted when joining and re-parsing happened to leave the array length unchanged after deduplication. Tests now assert the structured error fields via
Schema.is(OAuthScopeEncodingError).Reviewed by Cursor Bugbot for commit 6bfc53e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure OAuth scope encoding failures with
OAuthScopeEncodingErrorOAuthScopeEncodingError, a tagged error class carrying structured fields:scopes,invalidScopes, andduplicateScopes.encodeOAuthScopeto explicitly validate tokens viaOAUTH_SCOPE_TOKEN, detect duplicates with aSet, and reject empty input — replacing the previous round-trip throughparseOAuthScope.encodeOAuthScope([])now throwsOAuthScopeEncodingErrorinstead of returning an empty string; invalid or duplicate scope errors are now typed rather than genericError.Macroscope summarized 6bfc53e.