Skip to content

Conversation

@maoxiaowang
Copy link
Contributor

@maoxiaowang maoxiaowang commented Jan 7, 2026

Fix SDK authentication to return consistent error responses.

Previously, missing or invalid API keys returned HTTP 200 with inconsistent error messages and codes.
This made it unreliable for SDK clients to detect authentication failures and handle them correctly.

What problem does this PR solve?

  • Updated token_required decorator to:
    • Preserve tenant_id injection
    • Raise Unauthorized for missing or invalid API keys
  • Added a global app.errorhandler for Unauthorized:
    • Returns structured error response with HTTP 401
  • Authentication failures now consistently return either:
    • HTTP 401 or response code 401 (for legacy compatibility)

Frontend Impact

  • Frontend now properly handles HTTP 401 responses, and redirects to login page as expected.
  • No changes to existing pages or authentication logic.

Type of change

  • Performance Improvement

…so update frontend to redirect to login on HTTP 401
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant