codeant-ai-for-open-source[bot] commented on code in PR #44710:
URL: https://github.com/apache/superset/pull/44710#discussion_r4111462602
##########
superset/db_engine_specs/databricks.py:
##########
@@ -320,6 +320,37 @@ def _workspace_oauth2_endpoint(cls, database: Database,
path: str) -> str:
)
return f"https://{host}/oidc/v1/{path}"
+ @classmethod
+ def resolve_oauth2_client_info(
+ cls,
+ database: Database,
+ client_info: dict[str, Any],
+ ) -> dict[str, Any]:
+ """
+ Derive missing OAuth2 endpoints from the workspace host.
+
+ ``authorization_request_uri`` and ``token_request_uri`` are required by
+ ``OAuth2ClientConfigSchema``; without them the database's OAuth2 was
+ disabled (``is_oauth2_enabled`` returned False) and every connection
+ failed with a ValidationError. Each missing or empty endpoint becomes
+ ``https://<workspace-host>/oidc/v1/{authorize,token}``; explicit values
+ win. A connection without a host raises ``OAuth2Error``.
+ """
+ endpoints = {
+ "authorization_request_uri": "authorize",
+ "token_request_uri": "token",
+ }
+ missing = [key for key in endpoints if not client_info.get(key)]
+ if not missing:
+ return client_info
+ return {
+ **client_info,
+ **{
+ key: cls._workspace_oauth2_endpoint(database, endpoints[key])
+ for key in missing
+ },
+ }
Review Comment:
**Suggestion:** Resolved endpoints are returned by `get_oauth2_config()`,
but database updates compare them with raw omitted values, so every update
purges valid OAuth2 tokens.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Stale reference`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=39c4df0d2d314130bb49a95e7c4f4676&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=39c4df0d2d314130bb49a95e7c4f4676&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/db_engine_specs/databricks.py
**Line:** 343:352
**Comment:**
*Stale Reference: Resolved endpoints are returned by
`get_oauth2_config()`, but database updates compare them with raw omitted
values, so every update purges valid OAuth2 tokens.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44710&comment_hash=90a249152ad734a819ba0766cbcadd0c04492c8c96329a24e2094c4e1c6f7325&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44710&comment_hash=90a249152ad734a819ba0766cbcadd0c04492c8c96329a24e2094c4e1c6f7325&reaction=dislike'>๐</a>
##########
superset/models/core.py:
##########
@@ -1515,6 +1515,11 @@ def get_oauth2_config(self) -> OAuth2ClientConfig | None:
logger.error(ex, exc_info=True)
raise SupersetGenericDBErrorException(message=str(ex)) from ex
if oauth2_client_info := encrypted_extra.get("oauth2_client_info"):
+ # Let the engine spec fill values it can derive (e.g. endpoints
from
+ # the connection host) before the schema requires them.
+ oauth2_client_info =
self.db_engine_spec.resolve_oauth2_client_info(
+ self, oauth2_client_info
+ )
Review Comment:
**Suggestion:** The resolver runs before schema validation, so malformed
truthy values such as a string for `oauth2_client_info` reach Databricks
`.get()` and raise `AttributeError` instead of `ValidationError`.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Type error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ba36f24b43d1478e9906cff7a580d549&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ba36f24b43d1478e9906cff7a580d549&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/models/core.py
**Line:** 1520:1522
**Comment:**
*Type Error: The resolver runs before schema validation, so malformed
truthy values such as a string for `oauth2_client_info` reach Databricks
`.get()` and raise `AttributeError` instead of `ValidationError`.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44710&comment_hash=18df5e5905a5fe272245ecc6ccafe21e9a964cc18ae027adc446eb852a6381ae&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44710&comment_hash=18df5e5905a5fe272245ecc6ccafe21e9a964cc18ae027adc446eb852a6381ae&reaction=dislike'>๐</a>
--
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]