feat: Implement authentication error handling#12
Merged
ChingEnLin merged 1 commit intodevfrom Sep 2, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a centralized authentication error handling utility to standardize how authentication/session expiration errors are detected and reported across the frontend codebase, improving user experience with clear error messages and graceful session handling.
- Implemented a reusable
authErrorHandlerutility with functions for detecting expired sessions, generating user-friendly messages, and determining login redirects - Refactored database and user data services to use standardized error handling for token acquisition
- Enhanced UI error handling in QueryGeneratorPage to distinguish between authentication and permission errors
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/utils/authErrorHandler.ts | New utility providing authentication error detection and user-friendly messaging |
| frontend/tests/utils/authErrorHandler.test.ts | Comprehensive unit tests for the authentication error handler utility |
| frontend/services/userDataService.ts | Updated token acquisition to use centralized error handling |
| frontend/services/dbService.ts | Refactored to use helper function for authenticated token retrieval with proper error handling |
| frontend/pages/QueryGeneratorPage.tsx | Enhanced error handling to distinguish authentication vs permission errors |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
🎉 This PR is included in version 2.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a robust, reusable authentication error handling utility and applies it throughout the frontend codebase. The main goal is to standardize how authentication/session expiration errors are detected and reported, ensuring users receive clear, actionable error messages and that expired sessions are handled gracefully.
Key changes:
Authentication Error Handling Utility
Added a new
authErrorHandlerutility (frontend/utils/authErrorHandler.ts) that provides three main functions:isAuthenticationExpiredError,getAuthErrorMessage, andshouldRedirectToLogin. These help detect expired sessions, generate user-friendly error messages, and determine when to redirect users to the login page.Comprehensive unit tests were added for this utility in
frontend/__tests__/utils/authErrorHandler.test.ts, ensuring correct detection and messaging for various authentication error scenarios.Integration Across Services
dbService.tsanduserDataService.tsto use the new error handling utility. Token acquisition and API calls now use helper functions that catch authentication errors, throw user-friendly messages, and propagate other errors as-is. This improves reliability and consistency in error handling for all database and user data operations. [1] [2] [3] [4] [5] [6] [7] [8] [9]UI Error Handling Improvements
QueryGeneratorPage.tsxto use the new utility for displaying authentication errors to users. Now, session expiration and permission errors are clearly distinguished and shown with appropriate guidance, and authentication errors during background operations are logged for debugging. [1] [2] [3] [4]