aminghadersohi opened a new pull request, #44769:
URL: https://github.com/apache/superset/pull/44769
### SUMMARY
The database OAuth2 callback endpoint (`GET /api/v1/database/oauth2/`)
returned an
uncaught-exception 500 whenever the request couldn't legitimately succeed:
- the provider redirected back with an `error` parameter (user denied
consent, etc.)
- the `state` parameter was missing from the query string
- the `state` parameter was present but couldn't be decoded
(tampered/expired/malformed)
- the request had no authenticated session (or the session belonged to a
different user
than the one who started the flow)
None of these are server failures — they're all conditions the caller could
act on (deny
was intentional, or the user should retry the connection flow while logged
in) — so they
should be reported as 4xx responses with a readable message, not a 500.
This adds `OAuth2RejectedError` (HTTP 400) and raises it from the callback
command's
validation step for the four cases above. Actual token-exchange failures
against the
OAuth2 provider are a separate, genuinely server/provider-side problem and
keep mapping
to the existing 500 response — that behavior is unchanged.
### TESTING INSTRUCTIONS
- `pytest tests/unit_tests/commands/databases/oauth2_test.py
tests/unit_tests/databases/oauth2_api_test.py
tests/unit_tests/databases/api_test.py`
- New/updated tests cover: provider `error` param, missing `state`,
undecodable `state`,
and an anonymous (no session) request — each now asserts a 4xx response
instead of 500.
- Manually: hit `/api/v1/database/oauth2/?error=access_denied` (or omit
`state`, or pass
`state=garbage`) while logged out or logged in — the response is now `400`
with a
human-readable `message` instead of an unhandled-exception `500`.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]