You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/09/24 20:47:26 UTC
[PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44620:
URL: https://github.com/apache/superset/pull/44620#discussion_r4118822037
##########
tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py:
##########
@@ -1445,6 +1445,37 @@ async def test_dataset_access_denied_short_circuits(
assert error["error_type"] == "DatasetNotAccessible"
mock_create_form_data.assert_not_called()
+ @patch.object(update_chart_preview_module, "_find_dataset")
+ @patch("superset.daos.dataset.DatasetDAO.find_by_id")
+ @pytest.mark.asyncio
+ async def test_non_decimal_digit_dataset_id_uses_uuid_lookup(
+ self,
+ mock_find_by_id,
+ mock_find_dataset,
+ mcp_server,
+ mock_auth,
+ ):
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing test type hints</b></div>
<div id="fix">
BITO.md rules 7819 and 13155 mandate explicit return type hints on test methods (including async tests) and typed fixture parameters. This new async test declares neither: the signature ends with `):` and the `mcp_server`/`mock_auth` fixture params are untyped. Add `-> None:` and annotate the fixture params per the convention.
</div>
</div>
<small><i>Code Review Run #6dd3c2</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5822062007
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44620?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `6 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 57.12%. Comparing base ([`1c7d1f0`](https://app.codecov.io/gh/apache/superset/commit/1c7d1f049bce198966189dd29332cb3e3ca83977?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d10e9a2`](https://app.codecov.io/gh/apache/superset/commit/d10e9a258e3ec2165921ff4459c19a094006335d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/44620?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/daos/base.py](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&filepath=superset%2Fdaos%2Fbase.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFvcy9iYXNlLnB5) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/daos/datasource.py](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&filepath=superset%2Fdaos%2Fdatasource.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFvcy9kYXRhc291cmNlLnB5) | 0.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/chart\_helpers.py](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fchart_helpers.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvY2hhcnRfaGVscGVycy5weQ==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/tool/get\_chart\_sql.py](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fget_chart_sql.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZXRfY2hhcnRfc3FsLnB5) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/models/slice.py](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&filepath=superset%2Fmodels%2Fslice.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL3NsaWNlLnB5) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/utils/date\_parser.py](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&filepath=superset%2Futils%2Fdate_parser.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdXRpbHMvZGF0ZV9wYXJzZXIucHk=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44620?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44620 +/- ##
=======================================
Coverage 57.12% 57.12%
=======================================
Files 2955 2955
Lines 178362 178362
Branches 41319 41319
=======================================
Hits 101885 101885
Misses 75494 75494
Partials 983 983
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44620/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/44620/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.79% <0.00%> (ø)` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/44620/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.70% <0.00%> (ø)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/44620/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.75% <0.00%> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/44620?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5822060309
<!-- Bito Reply -->
The flagged issue is correct. The code uses `str.isdigit()` to check if an identifier is numeric before calling `int()`. However, `str.isdigit()` returns `True` for certain Unicode characters (like superscript digits) that `int()` cannot parse, leading to a `ValueError`. The fix is to use `str.isdecimal()`, which only returns `True` for characters that represent base-10 digits, ensuring `int()` will succeed.
The pull request already implements this fix across multiple files (`superset/daos/base.py`, `superset/daos/datasource.py`, `superset/mcp_service/chart/chart_helpers.py`, `superset/mcp_service/chart/chart_utils.py`, `superset/mcp_service/chart/tool/generate_chart.py`) and includes corresponding unit tests in `tests/unit_tests/dao/base_dao_test.py`, `tests/unit_tests/datasource/dao_tests.py`, and `tests/unit_tests/models/slice_test.py` to verify the behavior for non-decimal digits like "²".
**superset/daos/base.py**
```
- if model_id_or_uuid.isdigit():
+ if model_id_or_uuid.isdecimal():
filter = id_column == int(model_id_or_uuid)
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5859748516
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 10ab56034a1bd734ddd395f2d7b58d1bddb19971 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6ab98224510c0500083d8cc7 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-44620--superset-docs-preview.netlify.app](https://deploy-preview-44620--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctBDoQgDEDRu3Qtseqo6A08BrSoTRSIMIlm4t2H3V_894N4hTNmmAEqsJfxtJde5a4lsWyS1dcLBXYqiT3Eb0p8ymVzqQB28QjPwoUMxk66bT99g4Q9IuqONdEI7x8) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-44620--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5821989393
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5863703448
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers an incremental AI Review.
- `/review full` - Manually triggers a full AI Review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #44620:
URL: https://github.com/apache/superset/pull/44620
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5859731013
@aminghadersohi `filters.py:169` doesnt actually call `int()` on the digit-filtered ids, it passes them straight into `Dashboard.id.in_(...)`, so its the same no-int()-call shape as `get_chart_preview.py`s heuristic rather than the isdigit-then-int() pattern this PR is fixing. Fair on the count being off though.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5861886688
@aminghadersohi pinned 5 of those 7: `chart_helpers.resolve_form_data_datasource`, `get_chart_sql._resolve_datasource_name`, `generate_explore_link`, and both `update_chart_preview`'s and `generate_chart`'s dataset lookups. The other two `generate_chart` sites are buried deep enough in `CreateChartCommand` scaffolding that pinning them properly needs more mocking than felt safe to rush here.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #44620:
URL: https://github.com/apache/superset/pull/44620#discussion_r4116909641
##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -151,7 +151,7 @@ def find_chart_by_identifier(
{"query_options": query_options} if query_options is not None else {}
)
if isinstance(identifier, int) or (
- isinstance(identifier, str) and identifier.isdigit()
+ isinstance(identifier, str) and identifier.isdecimal()
Review Comment:
Added a regression test for each mcp_service resolver using a non-decimal digit like `²`, confirming it falls through to the uuid/slug branch instead of hitting `int()`. Should pin the rest of them now.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #44620:
URL: https://github.com/apache/superset/pull/44620#discussion_r4107259247
##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -151,7 +151,7 @@ def find_chart_by_identifier(
{"query_options": query_options} if query_options is not None else {}
)
if isinstance(identifier, int) or (
- isinstance(identifier, str) and identifier.isdigit()
+ isinstance(identifier, str) and identifier.isdecimal()
Review Comment:
Reverting all 13 `mcp_service` sites to `isdigit()` leaves `tests/unit_tests/mcp_service/` at 2198 passed / 3 skipped — identical to baseline, so none is pinned. The three DAO/Slice tests do kill their mutants; one parametrized `"²"` case over these resolvers would close the rest.
##########
superset/utils/date_parser.py:
##########
@@ -349,7 +349,7 @@ def handle_nth_of(
"DATETRUNC(..., year) : DATEADD(DATETRUNC(..., year), 1, week)"
"""
# Convert ordinal to number
- n = ORDINAL_MAP.get(ordinal.lower(), int(ordinal) if ordinal.isdigit() else 1)
+ n = ORDINAL_MAP.get(ordinal.lower(), int(ordinal) if ordinal.isdecimal() else 1)
Review Comment:
codeant is wrong here: the `dict.get` default is eager, but the ternary guards `int()` — `"first".isdecimal()` is False so it yields `1`, measured identical under both predicates. All three callers capture `(first|1st)`, both `ORDINAL_MAP` keys, so `int(ordinal)` is unreachable.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #44620:
URL: https://github.com/apache/superset/pull/44620#discussion_r4111224494
##########
superset/utils/date_parser.py:
##########
@@ -349,7 +349,7 @@ def handle_nth_of(
"DATETRUNC(..., year) : DATEADD(DATETRUNC(..., year), 1, week)"
"""
# Convert ordinal to number
- n = ORDINAL_MAP.get(ordinal.lower(), int(ordinal) if ordinal.isdigit() else 1)
+ n = ORDINAL_MAP.get(ordinal.lower(), int(ordinal) if ordinal.isdecimal() else 1)
Review Comment:
codeant's off here. The ternary already guards `int()`: `"first".isdecimal()` is False so it short-circuits to `1`, and `dict.get`'s eager default never actually runs on a word in practice.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44620:
URL: https://github.com/apache/superset/pull/44620#issuecomment-5861000953
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers an incremental AI Review.
- `/review full` - Manually triggers a full AI Review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: guard the isdigit()-then-int() pattern against non-decimal digits [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #44620:
URL: https://github.com/apache/superset/pull/44620#discussion_r4098359982
##########
superset/utils/date_parser.py:
##########
@@ -349,7 +349,7 @@ def handle_nth_of(
"DATETRUNC(..., year) : DATEADD(DATETRUNC(..., year), 1, week)"
"""
# Convert ordinal to number
- n = ORDINAL_MAP.get(ordinal.lower(), int(ordinal) if ordinal.isdigit() else 1)
+ n = ORDINAL_MAP.get(ordinal.lower(), int(ordinal) if ordinal.isdecimal() else 1)
Review Comment:
**Suggestion:** Python evaluates the `dict.get` default eagerly, so `int(ordinal)` raises for mapped words such as `first` before `ORDINAL_MAP` can return their value.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Often` · 🏷️ `Incorrect condition logic`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a30e86c88693461fbb214f68d1fa207c&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=a30e86c88693461fbb214f68d1fa207c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/utils/date_parser.py
**Line:** 352:352
**Comment:**
*Incorrect Condition Logic: Python evaluates the `dict.get` default eagerly, so `int(ordinal)` raises for mapped words such as `first` before `ORDINAL_MAP` can return their value.
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%2F44620&comment_hash=d70f34319262319e850b12d3d6a1ab02c4b253b2282f289cf3dfa640baead0be&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44620&comment_hash=d70f34319262319e850b12d3d6a1ab02c4b253b2282f289cf3dfa640baead0be&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org