codeant-ai-for-open-source[bot] commented on code in PR #45100:
URL: https://github.com/apache/superset/pull/45100#discussion_r4224480540
##########
superset/semantic_layers/models.py:
##########
@@ -166,6 +168,55 @@ class ColumnMetadata:
extra: str | None = None
+_METADATA_IDENTITY_KEY: str = "semantic_layer_cache_identity"
+
+
+@dataclass
+class _MetadataCacheIdentity:
+ """Session-local identities, captured before discovery and forgotten on
Save."""
+
+ tokens: dict[uuid.UUID, str] = field(default_factory=dict)
+
+ @classmethod
+ def for_session(cls, session: Session) -> _MetadataCacheIdentity:
+ """Keep the memo's storage convention in one place."""
+ if _METADATA_IDENTITY_KEY not in session.info:
+ session.info[_METADATA_IDENTITY_KEY] = cls()
+ return cast(_MetadataCacheIdentity,
session.info[_METADATA_IDENTITY_KEY])
+
+ def capture(self, layer: SemanticLayer, session: Session) -> str:
+ """Web, task and MCP operations share a credential-independent
identity."""
+ if layer.uuid not in self.tokens:
+ namespace: str | Callable[[], str] = current_app.config.get(
+ "SEMANTIC_LAYER_CACHE_NAMESPACE", ""
+ )
+ if callable(namespace):
+ namespace = namespace()
+ if not isinstance(namespace, str):
+ raise TypeError(
+ "SEMANTIC_LAYER_CACHE_NAMESPACE must resolve to a string"
+ )
+ url: sa.engine.URL =
session.get_bind(mapper=SemanticLayer).engine.url
Review Comment:
**Suggestion:** `Session.get_bind()` returns an `Engine` here, which has no
`.engine` attribute; the first metadata-token lookup raises `AttributeError`
and breaks semantic-view requests.
**Assessment:** ๐ด `Critical` ยท ๐ `Occurrence: Often` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=63f4974fd62b4a5989b41326735d881e&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=63f4974fd62b4a5989b41326735d881e&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/semantic_layers/models.py
**Line:** 199:199
**Comment:**
*Api Mismatch: `Session.get_bind()` returns an `Engine` here, which has
no `.engine` attribute; the first metadata-token lookup raises `AttributeError`
and breaks semantic-view requests.
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%2F45100&comment_hash=a45c4e2b5af1118c689923d3ce784f8c5233d82bef35180baf777315a4b7eeb9&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45100&comment_hash=a45c4e2b5af1118c689923d3ce784f8c5233d82bef35180baf777315a4b7eeb9&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]