codeant-ai-for-open-source[bot] commented on code in PR #37065:
URL: https://github.com/apache/superset/pull/37065#discussion_r2699232452
##########
superset-frontend/src/dashboard/components/nativeFilters/state.ts:
##########
@@ -250,7 +251,20 @@ export function useSelectFiltersInScope(filters: (Filter |
Divider)[]) {
if (filterInScope) {
filtersInScope.push(filter);
} else {
- filtersOutOfScope.push(filter);
+ // Skip adding tab-scoped filters to filtersOutOfScope if they're
not in scope.
+ // Filters scoped to inactive tabs (or sub-tabs) should be
completely hidden,
+ // not shown in "Filters out of scope" section.
+ // Only filters without explicit tab scope (rootPath is empty or
contains only ROOT_ID)
+ // should be shown in "Filters out of scope" when they're not
applicable.
+ const hasExplicitTabScope =
+ !isFilterDivider(filter) &&
Review Comment:
**Suggestion:** Runtime ReferenceError: `isFilterDivider` is not defined in
this file; using it will throw at runtime. Replace the undefined function call
with an existing, imported discriminator (use `filter.type !==
NativeFilterType.Divider`) to determine dividers, avoiding the missing-symbol
runtime error. [possible bug]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Native filters rendering may throw runtime ReferenceError.
- ❌ Dashboards with tabs can fail to render filters UI.
- ⚠️ Unit tests exercising this hook may error unexpectedly.
```
</details>
```suggestion
filter.type !== NativeFilterType.Divider &&
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the file defining the hook at
superset-frontend/src/dashboard/components/nativeFilters/state.ts, function
useSelectFiltersInScope (definition begins at line 236 in the PR hunk). The
problematic
expression is evaluated in the else branch starting at line 248 and the
hasExplicitTabScope check at lines 259-263 (PR hunk lines shown as 254-267).
2. Render any component that mounts the native filters hook (the hook
useSelectFiltersInScope located at state.ts:236) with dashboardHasTabs true
and at least
one filter where isFilterInScope(filter) returns false. During rendering the
forEach loop
(state.ts lines ~248-269) reaches the branch that evaluates the
hasExplicitTabScope
expression at the source location (PR hunk lines 259-263 / file lines
254-267).
3. When that expression runs, the code references !isFilterDivider(filter)
(state.ts line
shown 260). Because isFilterDivider is not defined or imported in this file,
a
ReferenceError is thrown at that exact evaluation point, interrupting render.
4. Observable outcome: the dashboard native-filters rendering path will
throw a runtime
ReferenceError in the browser console and the "Filters" UI (or whatever
component invoked
this hook) will fail to render for dashboards with tabs when any filter is
out-of-scope.
Fixing the call to use an in-file discriminator (filter.type !==
NativeFilterType.Divider)
prevents this crash.
```
</details>
<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/state.ts
**Line:** 260:260
**Comment:**
*Possible Bug: Runtime ReferenceError: `isFilterDivider` is not defined
in this file; using it will throw at runtime. Replace the undefined function
call with an existing, imported discriminator (use `filter.type !==
NativeFilterType.Divider`) to determine dividers, avoiding the missing-symbol
runtime error.
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.
```
</details>
--
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]