codeant-ai-for-open-source[bot] commented on code in PR #39894:
URL: https://github.com/apache/superset/pull/39894#discussion_r3456292348
##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx:
##########
@@ -185,6 +200,27 @@ const FilterValue: FC<FilterValueProps> = ({
const [isRefreshing, setIsRefreshing] = useState(false);
const dispatch = useDispatch();
+ // When a Date Range parent filter is active, the child filter needs
+ // granularity_sqla to apply the temporal WHERE clause. Read main_dttm_col
+ // from the Redux datasource cache as a fallback.
+ //
+ // The dashboard datasets API (/api/v1/dashboard/:id/datasets) only returns
+ // datasets used by chart slices, so native-filter-only datasets are never
+ // in state.datasources. Dispatch fetchDatasourceMetadata at mount time to
+ // populate the cache explicitly for those datasets.
+ const datasourceMainDttmCol = useSelector<RootState, string | undefined>(
+ state =>
+ datasetId != null
+ ? state.datasources?.[`${datasetId}__table`]?.main_dttm_col
+ : undefined,
+ );
+
+ useEffect(() => {
+ if (datasetId != null) {
+ dispatch(fetchDatasourceMetadata(`${datasetId}__table`));
Review Comment:
**Suggestion:** This dispatch triggers an async thunk that can reject, but
the promise is not handled in the effect. If the metadata request fails, it can
produce an unhandled promise rejection in the browser and silently skip
retry/error handling for this component lifecycle. Handle the returned promise
(or make the thunk non-throwing) so failures are explicitly managed. [possible
bug]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Native filter metadata failures surface only as console rejections.
- ⚠️ Date-range cascading may misbehave when metadata fetch fails.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In
`superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx`,
locate the `useEffect` that dispatches metadata fetches at lines 218-222.
When `datasetId
!= null`, it calls
`dispatch(fetchDatasourceMetadata(\`${datasetId}__table\`));` and does
not use the returned value or attach any error handler.
2. In `superset-frontend/src/dashboard/actions/datasources.ts:57-82`, see
that
`fetchDatasourceMetadata` returns the Promise from `SupersetClient.get`
(lines 71-73) and
chains `.then`/`.catch`. On error, the `.catch` at lines 78-80 deletes the
in-flight key
and rethrows the error, so the thunk ultimately returns a *rejected* Promise
when the
network call fails.
3. When a `FilterValue` component mounts for a filter with a `datasetId`,
the `useEffect`
runs and dispatches `fetchDatasourceMetadata`. If `SupersetClient.get`
rejects (for
example, due to a network error or 5xx from
`/superset/fetch_datasource_metadata`), the
thunk's Promise rejects and `dispatch` propagates that rejection to its
caller.
4. Because the `useEffect` neither `await`s the result in a `try/catch` nor
chains
`.catch` on `dispatch(fetchDatasourceMetadata(...))`, the rejection has no
handler at the
call site. In browsers, this manifests as an unhandled Promise rejection
(triggering the
`unhandledrejection` event/console warnings) while the component lifecycle
provides no
retry or user-visible error handling for the failed metadata load.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=50536b0cd505405dbf08bb8f9f2cb5c8&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=50536b0cd505405dbf08bb8f9f2cb5c8&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/FilterValue.tsx
**Line:** 220:220
**Comment:**
*Possible Bug: This dispatch triggers an async thunk that can reject,
but the promise is not handled in the effect. If the metadata request fails, it
can produce an unhandled promise rejection in the browser and silently skip
retry/error handling for this component lifecycle. Handle the returned promise
(or make the thunk non-throwing) so failures are explicitly managed.
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%2F39894&comment_hash=361bbd5c1eef41f9cb12b79fe1f5a525abfb3dc53e395a009e886d9401b7353f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39894&comment_hash=361bbd5c1eef41f9cb12b79fe1f5a525abfb3dc53e395a009e886d9401b7353f&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]