codeant-ai-for-open-source[bot] commented on code in PR #40905:
URL: https://github.com/apache/superset/pull/40905#discussion_r3664387568
##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/getControlItemsMap.tsx:
##########
@@ -66,6 +72,135 @@ const CleanFormItem = styled(FormItem)`
margin-bottom: 0;
`;
+/** Resolves the saved or default initial value for a control. */
+function resolveInitialValue(
+ controlItem: CustomControlItem,
+ filterToEdit?: ControlItemsProps['filterToEdit'],
+ customizationToEdit?: ControlItemsProps['customizationToEdit'],
+) {
+ return (
+ filterToEdit?.controlValues?.[controlItem.name] ??
+ customizationToEdit?.controlValues?.[controlItem.name] ??
+ controlItem?.config?.default ??
+ null
+ );
+}
+
+/** Renders a StyledLabel with an optional description tooltip. */
+function ControlLabel({
+ label,
+ description,
+ fallbackLabel,
+}: {
+ label?: BaseControlConfig['label'];
+ description?: BaseControlConfig['description'];
+ fallbackLabel?: ReactNode;
+}) {
+ // Only zero-argument label/description functions are safe to invoke here:
+ // (state, controlState, chartState) are supplied by the Explore control
+ // panel renderer (ControlPanelsContainer), which this filter-config-modal
+ // control list does not have access to.
+ const resolvedLabel =
+ (typeof label === 'function'
+ ? label.length === 0
+ ? (label as () => ReactNode)()
+ : undefined
+ : label) ?? fallbackLabel;
+ const resolvedDescription =
+ typeof description === 'function'
+ ? description.length === 0
+ ? (description as () => ReactNode)()
+ : undefined
+ : description;
+ return (
+ <StyledLabel>
+ {resolvedLabel}
+ {resolvedDescription != null && (
+ <>
+
+ <InfoTooltip placement="top" tooltip={resolvedDescription} />
+ </>
+ )}
+ </StyledLabel>
+ );
+}
+
+function DatasetColumnSelect({
+ datasetId,
+ value,
+ onChange,
+}: {
+ datasetId?: number;
+ value?: string | null;
+ onChange?: (value: string | null) => void;
+}) {
+ const [{ loadedForId, fetchedColumns }, setFetchState] = useState<{
+ loadedForId?: number;
+ fetchedColumns: string[];
+ }>({ fetchedColumns: [] });
+
+ // Read via ref inside the async handlers below so a value change that
+ // happens while the request is in flight is validated against the
+ // current value, not the one captured when the effect started.
+ const valueRef = useRef(value);
+ valueRef.current = value;
+
+ const loading = !!(datasetId && loadedForId !== datasetId);
+ const options = loadedForId === datasetId ? fetchedColumns : [];
+
+ useEffect(() => {
+ if (!datasetId) {
+ // dataset cleared — drop any stale selection immediately
+ if (value) {
+ onChange?.(null);
+ }
+ return undefined;
+ }
+ let cancelled = false;
+ cachedSupersetGet({
+ endpoint: `/api/v1/dataset/${datasetId}?q=${rison.encode({
+ columns: ['columns.column_name'],
+ })}`,
+ })
Review Comment:
**Suggestion:** The new picker ignores `datasourceType` and always requests
the dataset endpoint. For semantic-view filters, this endpoint does not provide
the semantic view dimensions used by the existing `ColumnSelect`, so
plugin-declared column controls will fail or show no usable columns. Pass the
datasource type through and use the semantic-view structure endpoint when
appropriate. [api mismatch]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Semantic-view plugin column controls show no usable options.
- ⚠️ Dataset column selection works only for table datasources.
- ❌ Saved semantic-view control values cannot be selected or validated.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the native-filter configuration form;
`FiltersConfigForm.tsx:437-457` calls
`getControlItemsMap()` with the current `datasourceType`, including
`DatasourceType.SemanticView` resolved at `FiltersConfigForm.tsx:407-419`.
2. Use a plugin control with `config.isColumnSelect === true`;
`getControlItemsMap.tsx:383-427` renders `DatasetColumnSelect` for that
control.
3. With a semantic-view datasource selected, `DatasetColumnSelect` still
executes the
dataset request at `getControlItemsMap.tsx:160-164`, requesting
`/api/v1/dataset/{id}` and
expecting `result.columns` at `getControlItemsMap.tsx:165-170`.
4. The existing datasource-aware `ColumnSelect` demonstrates the required
behavior at
`ColumnSelect.tsx:84-110`: semantic views use
`/api/v1/semantic_view/{id}/structure` and
read `result.dimensions`. Therefore the new picker receives no usable
semantic-view
columns (and may enter its catch path after `result.columns` access fails),
leaving the
plugin control empty.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c49b97220edf454d8c819f1b212fd478&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=c49b97220edf454d8c819f1b212fd478&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/getControlItemsMap.tsx
**Line:** 160:164
**Comment:**
*Api Mismatch: The new picker ignores `datasourceType` and always
requests the dataset endpoint. For semantic-view filters, this endpoint does
not provide the semantic view dimensions used by the existing `ColumnSelect`,
so plugin-declared column controls will fail or show no usable columns. Pass
the datasource type through and use the semantic-view structure endpoint when
appropriate.
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%2F40905&comment_hash=2505c72392d21ef3fe9f1e4ae72943883e6beed2a8e034152e198469ea37354d&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40905&comment_hash=2505c72392d21ef3fe9f1e4ae72943883e6beed2a8e034152e198469ea37354d&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]