rusackas opened a new pull request, #44620:
URL: https://github.com/apache/superset/pull/44620

   ### SUMMARY
   
   Follow-up to #44615, which fixed `cast_to_num()` raising `ValueError` on 
strings like `"²"` or `"①"`: `str.isdigit()` is `True` for Unicode "digit" 
characters (category `No`), but `int()` only accepts "decimal" characters 
(category `Nd`), so an `isdigit()`-then-`int()` guard doesn't actually guard 
against everything it looks like it does.
   
   That review turned up the identical pattern repeated across the codebase 
wherever a string identifier gets resolved to a numeric ID: `if 
value.isdigit(): int(value)`. Swept `isdigit()` → `isdecimal()` at each 
unguarded call site:
   
   - `superset/daos/base.py`, `daos/datasource.py`, `models/slice.py` — shared 
id-or-uuid resolution used across every DAO and `Slice` lookup in the app.
   - `superset/utils/date_parser.py` — ordinal parsing in `handle_nth_of()`.
   - `superset/mcp_service/chart/{chart_helpers,chart_utils}.py` and the 
chart/dashboard/explore `mcp_service` tool modules (`generate_chart`, 
`get_chart_sql`, `update_chart_preview`, `dataset_validator`, 
`delete_dashboard`, `generate_explore_link`) — `dataset_id`/`identifier` 
resolution on MCP tool entry points, directly reachable from external 
LLM-client input.
   
   Left three other `isdigit()` call sites alone, on purpose:
   - `commands/dashboard/export.py` already wraps the `int()` call in 
`try/except ValueError`.
   - `get_chart_preview.py`'s form-data-key heuristic never calls `int()` on 
the value at all.
   - `sql/parse.py`'s KQL tokenizer is a different risk shape (regex-driven 
lexing) that deserves its own review rather than a mechanical swap.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A — backend-only bug fix.
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest tests/unit_tests/dao/base_dao_test.py 
tests/unit_tests/models/slice_test.py tests/unit_tests/datasource/dao_tests.py
   pytest tests/unit_tests/mcp_service/chart/ 
tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py 
tests/unit_tests/mcp_service/explore/
   ```
   
   Added regression tests for the three most widely-shared call sites 
(`BaseDAO.find_by_id_or_uuid`, `DatasourceDAO.get_datasource`, `Slice`'s 
`id_or_uuid_filter`), each confirming a non-decimal digit string like `"²"` 
falls through to the uuid branch instead of crashing. The other call sites 
share the exact same one-line fix and are covered by this PR's own full test 
suite run (2198 tests, 0 failures).
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to