codeant-ai-for-open-source[bot] commented on code in PR #43222:
URL: https://github.com/apache/superset/pull/43222#discussion_r3789510384
##########
superset/common/query_context_processor.py:
##########
@@ -442,9 +460,7 @@ def ensure_totals_available(
result = self._query_context.get_query_result(totals_query)
df = result.df
- totals = {
- col: df[col].sum() for col in df.columns if df[col].dtype.kind in
"biufc"
- }
+ totals = {col: df[col].sum() for col in df.columns if
_is_summable(df[col])}
Review Comment:
**Suggestion:** The raw `Decimal` totals are injected into query
post-processing and then into the query-context cache values. When
`cache_key()` hashes those values, `json_int_dttm_ser` converts `Decimal` to
`float`, which can collapse distinct high-precision totals to the same cache
key. A cached context can therefore be reused for a different total and render
incorrect contribution percentages; serialize Decimal values without lossy
float conversion or exclude these runtime totals from the context cache key.
[cache]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Async chart responses can use stale contribution totals.
- ❌ High-precision Decimal contribution percentages become incorrect.
- ⚠️ Affected flow requires query-context caching and precision loss.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6620cad75d1c41769752787981aafe87&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=6620cad75d1c41769752787981aafe87&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/common/query_context_processor.py
**Line:** 463:463
**Comment:**
*Cache: The raw `Decimal` totals are injected into query
post-processing and then into the query-context cache values. When
`cache_key()` hashes those values, `json_int_dttm_ser` converts `Decimal` to
`float`, which can collapse distinct high-precision totals to the same cache
key. A cached context can therefore be reused for a different total and render
incorrect contribution percentages; serialize Decimal values without lossy
float conversion or exclude these runtime totals from the context cache key.
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%2F43222&comment_hash=ce28f73b230b16efccc2660d74c04383f9acdec145d8c1e6a03c6ec81fe5900f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43222&comment_hash=ce28f73b230b16efccc2660d74c04383f9acdec145d8c1e6a03c6ec81fe5900f&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]