-
Couldn't load subscription status.
- Fork 26
Improve auth errors #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve auth errors #258
Conversation
🦋 Changeset detectedLatest commit: cd745f0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The updated error response looks really nice. The implementation looks solid from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves authentication error messaging and logging by standardizing error codes and enhancing error details across various auth‐related modules. Key changes include:
- Extending the AuthorizationError to include finer-grained token and configuration details.
- Updating error codes and messages in auth tests and across key collection and token verification modules.
- Adjusting error handling and property naming (e.g. token_error vs. token_errors) for consistency.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/service-errors/src/errors.ts | Updated AuthorizationError constructor to accept dynamic error codes and add detailed logging data. |
| packages/service-errors/src/codes.ts | Added new error code definitions and documentation. |
| packages/service-core/test/src/auth.test.ts | Updated test assertions to match the new error messages with error code prefixes. |
| packages/service-core/src/routes/* | Refactored type definitions and error handling in auth and router files. |
| packages/service-core/src/auth/* | Enhanced JWT verification and key store error handling with standardized error responses. |
| modules/module-postgres/src/auth/SupabaseKeyCollector.ts | Adjusted error handling for missing JWT secrets using the new AuthorizationError. |
| libs/lib-services/src/router/* | Updated endpoint and authorization response handling to use the standardized errors. |
Comments suppressed due to low confidence (2)
packages/service-core/src/routes/router.ts:19
- The property name was updated from 'token_errors' to 'token_error' for consistency. Verify that any references to this property in other parts of the codebase have been updated.
token_error?: ServiceError;
packages/service-core/src/routes/auth.ts:108
- The response structure now uses 'error' instead of 'errors' to report authorization failures. Please ensure that all downstream consumers of AuthorizationResponse are updated accordingly.
error: new AuthorizationError(ErrorCode.PSYNC_S2106, 'Authentication required')
This aims to provide more useful error messages when auth fails, by:
Examples
For each example, the first line is in the error response, second line is in logs only.
In most of these examples, a big gain is having the token header and payload in the logs. In some cases, the details of the key that the token is compared to may also help. The cause in the logs also help.