Skip to content

Automatic 401 Error Handling#138

Open
ShubhamChouksey123 wants to merge 1 commit intoLeetPushExtension:masterfrom
ShubhamChouksey123:bug-fix-401
Open

Automatic 401 Error Handling#138
ShubhamChouksey123 wants to merge 1 commit intoLeetPushExtension:masterfrom
ShubhamChouksey123:bug-fix-401

Conversation

@ShubhamChouksey123
Copy link

@ShubhamChouksey123 ShubhamChouksey123 commented Feb 23, 2026

Automatic 401 Error Handling:

  • Detects authentication errors by checking if the error message contains "401", "Authentication failed", or "invalid or expired"
  • Automatically clears the invalid token and branch from localStorage
  • Shows a clear error message explaining the issue
  • Automatically opens the config modal so the user can immediately enter new credentials

For Other Errors:

  • Maintains the existing error handling behavior (shows error state on button, generic error message)

How It Works

When the user clicks "Push" with an expired/invalid token:

  1. GitHub API returns 401 Unauthorized
  2. The pushFileToRepo function throws: "Authentication failed. Your GitHub token may be invalid or expired."
  3. The catch block in handlePushClick detects this is an auth error
  4. Clears the bad token from localStorage
  5. Shows an alert explaining the token is invalid
  6. Opens the config modal for the user to enter a new token

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.

2 participants