Skip to content

Sanitize user facing error - #8721

Merged
atavism merged 6 commits into
mainfrom
jigar/sanitize-error
May 4, 2026
Merged

Sanitize user facing error#8721
atavism merged 6 commits into
mainfrom
jigar/sanitize-error

Conversation

@jigar-f

@jigar-f jigar-f commented May 1, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces improvements to error handling and user feedback across the codebase, especially for VPN-related errors. It standardizes error logging, enhances user-facing error messages with more descriptive and categorized responses, and updates localization resources accordingly. Additionally, it removes an obsolete test file.

Error Handling and User Feedback Improvements

  • Introduced a VPN error classification system in error.dart that maps technical error messages to user-friendly, localized error strings using regex patterns. This ensures users see clearer and more actionable error messages for common VPN issues.
  • Added new localized error message keys and strings to en.po for various VPN and connection errors, supporting the new error categorization.

Standardization of Logging and Error Reporting

  • Updated all error logging statements throughout the app to consistently log the raw error field rather than the localized error message, making logs more useful for debugging. This affects many files, including account, authentication, payment, server, and VPN-related features. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]

VPN Service Error Handling

  • Improved error handling in lantern_ffi_service.dart by ensuring that errors returned from VPN start/stop operations are both logged and mapped to localized error descriptions, providing a better user experience and more actionable logs. [1] [2] [3]

Codebase Cleanup

  • Removed the obsolete test file app_setting_auth_session_test.dart, cleaning up unused or redundant tests.

@jigar-f jigar-f changed the title Ssanitize user facing error Sanitize user facing error May 1, 2026
@jigar-f jigar-f self-assigned this May 1, 2026
@jigar-f
jigar-f marked this pull request as ready for review May 1, 2026 11:36
Copilot AI review requested due to automatic review settings May 1, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 sanitizes user-facing errors—particularly VPN-related ones—by introducing a regex-based VPN error classification that maps technical errors to localized, user-friendly messages, while standardizing logging to record raw (non-localized) error details for debugging.

Changes:

  • Add VPN error classification in the shared error localization extension and use it for VPN start/stop and split-tunnel failures.
  • Standardize error logging across multiple features to log failure.error (raw) instead of failure.localizedErrorMessage.
  • Update English localization resources with new VPN/connection error strings and remove an obsolete auth/session-related test.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/core/models/app_setting_auth_session_test.dart Removes an app setting auth/session unit test.
lib/lantern/lantern_ffi_service.dart Logs VPN start/stop errors and maps raw FFI errors to localized descriptions.
lib/features/vpn/vpn_switch.dart Logs raw VPN state-change errors instead of localized messages.
lib/features/vpn/server_selection.dart Logs raw VPN connection errors on retry failures.
lib/features/vpn/provider/available_servers_notifier.dart Logs raw errors when loading available servers fails.
lib/features/system_tray/provider/system_tray_notifier.dart Logs raw errors for tray-driven connect failures.
lib/features/private_server/private_server_deploy.dart Logs raw errors when canceling a deployment fails.
lib/features/private_server/manually_server_setup.dart Logs raw errors when adding a server fails.
lib/features/plans/provider/plans_notifier.dart Removes a plan-selection info log line.
lib/features/macos_extension/macos_extension_dialog.dart Logs raw errors for macOS extension flow failures.
lib/features/language/language.dart Logs raw errors when locale updates fail.
lib/features/home/provider/home_notifier.dart Logs raw errors for user data fetch/refresh flows.
lib/features/home/provider/feature_flag_notifier.dart Logs raw errors for feature flag fetch failures.
lib/features/auth/create_password.dart Logs raw errors for create-password failures.
lib/features/auth/choose_payment_method.dart Logs raw errors for payment redirect failures.
lib/features/account/delete_account.dart Logs raw errors for account deletion failures.
lib/features/account/account.dart Logs raw errors for logout failures.
lib/core/services/app_purchase.dart Logs raw errors when purchase-related user data fetch fails.
lib/core/extensions/error.dart Adds VPN error regex classification and makes default user-facing errors more generic/sanitized.
assets/locales/en.po Adds new English strings for VPN/connection error categories.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread assets/locales/en.po
Comment on lines +1527 to +1537
msgid "err_check_connection"
msgstr "Unable to connect. Check your internet connection."

msgid "err_service_unavailable"
msgstr "Service temporarily unavailable. Trying again..."

msgid "err_connection_failed"
msgstr "Connection failed. Please try again."

msgid "err_ruleset_failed"
msgstr "Unable to load routing configuration. Retrying..."

Copilot AI May 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new VPN error message keys (err_check_connection, err_service_unavailable, err_connection_failed, err_ruleset_failed) are only added to en.po. If the app locale is set to something else, i18n lookups for these keys may fall back to showing the raw msgid (e.g., "err_check_connection") to users. Please add these msgids to the other locale .po files (even as English placeholders) or implement a fallback to English for missing keys.

Copilot uses AI. Check for mistakes.
Comment thread lib/core/extensions/error.dart Outdated
Comment thread lib/core/extensions/error.dart Outdated
@jigar-f
jigar-f requested a review from atavism May 1, 2026 12:19
@atavism

atavism commented May 4, 2026

Copy link
Copy Markdown
Contributor

LGTM

@atavism
atavism merged commit f8296b2 into main May 4, 2026
8 checks passed
@atavism
atavism deleted the jigar/sanitize-error branch May 4, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants