fix: restore typed data on AuthenticationErrorData#1570
Conversation
📝 WalkthroughWalkthroughA test fixture import is renamed in the serializers test file, and the authentication exception error payload interface is refined with stricter typing for the user field and an additional optional connection_ids field. Changes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR restores type safety on Confidence Score: 5/5Safe to merge — changes are additive, type-only improvements with no runtime behavior changes. All changes are compile-time type improvements ( No files require special attention. Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class WorkOSErrorData {
+code: string
+message: string
}
class AuthenticationErrorData {
+code: AuthenticationErrorCode
+pending_authentication_token?: string
+user?: UserResponse
+organizations?: Array~id, name~
+connection_ids?: string[]
}
class UserResponse {
+object: 'user'
+id: string
+email: string
+email_verified: boolean
+profile_picture_url: string | null
+first_name: string | null
+last_name: string | null
+last_sign_in_at: string | null
+locale: string | null
+created_at: string
+updated_at: string
+external_id?: string
+metadata?: Record~string, string~
}
class AuthenticationException {
+name: 'AuthenticationException'
+pendingAuthenticationToken: string | undefined
+rawData: AuthenticationErrorData
+constructor(status, rawData, requestID)
}
WorkOSErrorData <|-- AuthenticationErrorData : extends
AuthenticationErrorData --> UserResponse : user?
AuthenticationException --> AuthenticationErrorData : rawData
Reviews (1): Last reviewed commit: "enhance types on `AuthenticationErrorDat..." | Re-trigger Greptile |
AuthenticationErrorDataAuthenticationErrorData
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/common/exceptions/authentication.exception.ts`:
- Around line 18-20: The type guard isAuthenticationErrorData must validate the
optional fields to match the stricter AuthenticationErrorData shape: update
isAuthenticationErrorData (the runtime check around code) to also ensure that if
user is present it is an object with the expected UserResponse properties (e.g.,
id is a string and other key fields exist), that connection_ids (if present) is
an array whose every item is a string, and that organizations (if present) is an
array of objects each with string id and name; return false if any of these
checks fail so the guard truly narrows to AuthenticationErrorData.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 04149f6e-ac1f-4ff7-9e48-a207128324da
📒 Files selected for processing (2)
src/admin-portal/serializers.spec.tssrc/common/exceptions/authentication.exception.ts
Summary
user?: Record<string, unknown>with the concreteUserResponsetype onAuthenticationErrorData, restoring type safety for authentication error payloadsconnection_ids?: string[]field toAuthenticationErrorDataSSOIntentOptionsFixtureimport (PascalCase → camelCase to match other fixture imports)Test plan
AuthenticationErrorData.userresolves toUserResponsein IDE type-checkingconnection_idsfield is accessible onAuthenticationErrorDatanpm test— existing tests pass, including the renamed fixture import inserializers.spec.tsSummary by CodeRabbit
Tests
Refactor