codeant-ai-for-open-source[bot] commented on code in PR #42539:
URL: https://github.com/apache/superset/pull/42539#discussion_r3730093266
##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.tsx:
##########
@@ -377,14 +426,24 @@ const GroupByFilterCard: FC<GroupByFilterCardProps> = ({
? value
: null;
+ // Preserve datasourceType (and datasetId) when rebuilding the
+ // target: dropping the type here would silently degrade a
+ // semantic-view binding to the colliding regular dataset on the
+ // next resolution (sc-111089 review finding).
const targets: [Partial<NativeFilterTarget>] = columnValue
? ([
{
datasetId: dataset,
+ ...(datasourceType ? { datasourceType } : {}),
column: { name: columnValue },
},
] as [Partial<NativeFilterTarget>])
- : ([{}] as [Partial<NativeFilterTarget>]);
+ : ([
+ {
+ datasetId: dataset,
+ ...(datasourceType ? { datasourceType } : {}),
+ },
+ ] as [Partial<NativeFilterTarget>]);
Review Comment:
**Suggestion:** The hook normalizes legacy string and `{value}` dataset IDs
only for fetching, but these target rewrites persist the original unnormalized
value. Editing or clearing a legacy target can therefore send a string or
object as `datasetId` in the pending customization and directly in
`saveChartCustomization`, violating the numeric target contract and potentially
causing backend serialization or datasource resolution failures. Persist
`normalizedDatasetId` instead of `dataset` when rebuilding the target. [api
mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Legacy dynamic-group-by edits can submit malformed dataset targets.
- ❌ Saving affected customizations may fail backend validation.
- ⚠️ Subsequent datasource resolution may receive an object instead of an ID.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d115d058ebd84343a31aef5bbdc1df98&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=d115d058ebd84343a31aef5bbdc1df98&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/GroupByFilterCard.tsx
**Line:** 433:446
**Comment:**
*Api Mismatch: The hook normalizes legacy string and `{value}` dataset
IDs only for fetching, but these target rewrites persist the original
unnormalized value. Editing or clearing a legacy target can therefore send a
string or object as `datasetId` in the pending customization and directly in
`saveChartCustomization`, violating the numeric target contract and potentially
causing backend serialization or datasource resolution failures. Persist
`normalizedDatasetId` instead of `dataset` when rebuilding the target.
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%2F42539&comment_hash=1c5cc4b52b035e801d2a7ede4fc52500a01f63e98542aae521a11b0bc2e3dbcc&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42539&comment_hash=1c5cc4b52b035e801d2a7ede4fc52500a01f63e98542aae521a11b0bc2e3dbcc&reaction=dislike'>👎</a>
##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx:
##########
@@ -116,23 +117,9 @@ export function ColumnSelect({
};
if (datasourceType === DatasourceType.SemanticView) {
- cachedSupersetGet({
- endpoint: `/api/v1/semantic_view/${datasetId}/structure`,
- })
- .then((response: JsonResponse) => {
- const { dimensions = [] } = response.json?.result ?? {};
- const cols: Column[] = dimensions.map(
- (dim: { name: string; type: string }) => {
- const mappedType = mapSemanticTypeToGenericDataType(dim.type);
- return {
- column_name: dim.name,
- type: dim.type,
- is_dttm: mappedType === GenericDataType.Temporal,
- type_generic: mappedType,
- filterable: true,
- };
- },
- );
+ fetchSemanticViewStructure(datasetId)
Review Comment:
**Suggestion:** The semantic-view request has no binding check before
updating state. If the dataset ID or datasource type changes while this request
is pending, its completion can reset the new field value, replace the new
datasource's columns with stale dimensions, and set `loading` to false while
the newer request is still active. Track a request/binding identity and ignore
stale success, error, and finally callbacks. [race condition]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Filter configuration can show columns from the previous datasource.
- ⚠️ Current column values may be reset using stale dimensions.
- ⚠️ Loading state can end before the active request completes.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f8f75d4b06114506a603b6fcd0e25919&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=f8f75d4b06114506a603b6fcd0e25919&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/ColumnSelect.tsx
**Line:** 120:132
**Comment:**
*Race Condition: The semantic-view request has no binding check before
updating state. If the dataset ID or datasource type changes while this request
is pending, its completion can reset the new field value, replace the new
datasource's columns with stale dimensions, and set `loading` to false while
the newer request is still active. Track a request/binding identity and ignore
stale success, error, and finally callbacks.
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%2F42539&comment_hash=163fde10429d0a351d6cf091c1faf1abca8d7bc95165e2f5ae5b3bdb01248f5b&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42539&comment_hash=163fde10429d0a351d6cf091c1faf1abca8d7bc95165e2f5ae5b3bdb01248f5b&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]