codeant-ai-for-open-source[bot] commented on code in PR #40804: URL: https://github.com/apache/superset/pull/40804#discussion_r3364217342
########## superset-frontend/plugins/preset-chart-deckgl/src/utilities/Shared_DeckGL.tsx: ########## @@ -73,13 +88,27 @@ export const DEFAULT_MAPBOX_TILES = [ ['mapbox://styles/mapbox/outdoors-v9', 'Outdoors (Mapbox)'], ]; +const isDeckGLTileChoices = (value: unknown): value is DeckGLTileChoice[] => + Array.isArray(value) && + value.every( + choice => + Array.isArray(choice) && + choice.length >= 2 && + typeof choice[0] === 'string' && + typeof choice[1] === 'string', + ); Review Comment: **Suggestion:** The tile-choice validator accepts an empty array as valid, so a deployment with `DECKGL_BASE_MAP=[]` will set `deckglTiles` to `[]` and later crash when `maplibreStyle` reads `getDeckGLTiles()[0][0]`. Tighten the validator to require at least one entry (and ideally exactly two string elements per choice) before accepting overrides, otherwise fall back to `DEFAULT_DECKGL_TILES`. [incorrect condition logic] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ❌ DeckGL Explore controls crash when DECKGL_BASE_MAP is empty. - ⚠️ All DeckGL map layers become unusable under misconfiguration. - ⚠️ Admins cannot rely on empty list as override. ``` </details> <details> <summary><b>Steps of Reproduction ✅ </b></summary> ```mdx 1. Configure Superset with an empty DeckGL base map list by setting `DECKGL_BASE_MAP = []` in `superset_config.py` as described in `docs/admin_docs/configuration/map-tiles.mdx:13-34`. When the server builds bootstrap data in `superset/views/base.py:16`, it copies this configuration into the `"deckgl_tiles"` field of the `bootstrap_data` dict. 2. Start the Superset web server so that the frontend receives `deckgl_tiles: []` in the bootstrap payload embedded in the HTML, which is then read by `getBootstrapDataFromDocument()` inside `superset-frontend/plugins/preset-chart-deckgl/src/utilities/Shared_DeckGL.tsx` (see the `getDeckGLTiles` function around lines 22–32 in the Read output). 3. In the browser, open Explore for any DeckGL-based chart such as the Hex layer (`superset-frontend/plugins/preset-chart-deckgl/src/layers/Hex/controlPanel.ts:25-47`), which imports `maplibreStyle` from `../../utilities/Shared_DeckGL` and includes it in the `"Map"` control section. 4. When the control panel renders, `maplibreStyle.config` in `Shared_DeckGL.tsx` (shown in the Read output lines 21–31) evaluates `choices: getDeckGLTiles()` and `default: getDeckGLTiles()[0][0]`. Because `isDeckGLTileChoices` (PR lines 91–99) treats `[]` as valid, `getDeckGLTiles()` returns `[]`, so `getDeckGLTiles()[0]` is `undefined` and `[0]` access throws a runtime error in the browser, breaking the Explore UI for DeckGL charts under this configuration. ``` </details> [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=35af6f5458ff4801b4a3374f8ded60ff&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=35af6f5458ff4801b4a3374f8ded60ff&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/plugins/preset-chart-deckgl/src/utilities/Shared_DeckGL.tsx **Line:** 91:99 **Comment:** *Incorrect Condition Logic: The tile-choice validator accepts an empty array as valid, so a deployment with `DECKGL_BASE_MAP=[]` will set `deckglTiles` to `[]` and later crash when `maplibreStyle` reads `getDeckGLTiles()[0][0]`. Tighten the validator to require at least one entry (and ideally exactly two string elements per choice) before accepting overrides, otherwise fall back to `DEFAULT_DECKGL_TILES`. 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%2F40804&comment_hash=846364058ab18d1e6b85cfdc6f9542a0fd8f67b9c8eb2e842d7d67ce437dd2b5&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40804&comment_hash=846364058ab18d1e6b85cfdc6f9542a0fd8f67b9c8eb2e842d7d67ce437dd2b5&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]
