Conversation
Member
appleboy
commented
Feb 27, 2026
- Introduce error sanitization for OAuth and token exchange errors to prevent sensitive information disclosure in browser messages
- Show user-friendly, sanitized error messages in the browser, while retaining full error details in the terminal output
- Add tests verifying that browser messages do not leak backend details and remain generic
- Add utility functions for error sanitization and testing their correctness
- Introduce error sanitization for OAuth and token exchange errors to prevent sensitive information disclosure in browser messages - Show user-friendly, sanitized error messages in the browser, while retaining full error details in the terminal output - Add tests verifying that browser messages do not leak backend details and remain generic - Add utility functions for error sanitization and testing their correctness Signed-off-by: appleboy <appleboy.tw@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds an error-sanitization layer for the browser-facing OAuth callback UI so that sensitive backend/auth details remain in terminal output while the browser only shows generic, user-friendly messages.
Changes:
- Introduces
sanitizeOAuthErrorandsanitizeTokenExchangeErrorhelpers to generate browser-safe messages. - Updates the callback handler to render sanitized messages in the browser while still returning detailed errors to the caller (terminal/TUI path).
- Adds/updates tests to verify browser pages don’t leak detailed OAuth/token-exchange failure information.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| callback.go | Writes only sanitized failure messages to the browser and preserves detailed errors in returned error. |
| callback_test.go | Extends callback flow tests to assert browser output is sanitized while terminal error retains details. |
| error_sanitizer.go | Adds sanitization utilities used by the callback handler. |
| error_sanitizer_test.go | Adds unit tests for sanitization helpers and substring-check utility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove the containsAny helper function and its associated tests - Change sanitizeTokenExchangeError to ignore the error parameter entirely for improved security Signed-off-by: appleboy <appleboy.tw@gmail.com>
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.