codeant-ai-for-open-source[bot] commented on code in PR #44352:
URL: https://github.com/apache/superset/pull/44352#discussion_r4031923812
##########
superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx:
##########
@@ -48,16 +48,15 @@ import { Styles } from './Styles';
* Pivot keys are stringified on their way through `PivotData`, so a temporal
* header holding an epoch timestamp arrives as e.g. "1700000000000". Coerce
* such numeric strings back to numbers so temporal formatters (which expect
- * an epoch) render correctly. A bare four-digit string is the ISO 8601
- * year-only form ("2017"), which the shared `stringifyTimeInput` in core
- * reads as that calendar year; coercing it would turn the year into two
- * seconds past 1970, so it is passed through untouched.
+ * an epoch) render correctly. Only a digit-only string of at least 10 digits
+ * is long enough to plausibly be an epoch in milliseconds; shorter ones are
+ * date keys or plain integers - "2017" is the ISO 8601 year-only form and
+ * "20260903" a YYYYMMDD key - and coercing either would render it as a moment
+ * near 1970. Those are passed through as strings, which the shared
+ * `stringifyTimeInput` in core resolves or returns untouched.
*/
const toDateFormatterInput = (value: unknown): unknown =>
- typeof value === 'string' &&
- value.trim() !== '' &&
- !/^\d{4}$/.test(value.trim()) &&
- Number.isFinite(Number(value))
+ typeof value === 'string' && /^-?\d{10,}$/.test(value.trim())
? Number(value)
Review Comment:
**Suggestion:** Short numeric date keys remain strings when rendered, but
cross-filter and drill-filter paths still convert them to numbers, sending a
value different from the selected header. [api mismatch]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a30f712790794f3ba1bb5151ce3e4350&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=a30f712790794f3ba1bb5151ce3e4350&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-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx
**Line:** 59:60
**Comment:**
*Api Mismatch: Short numeric date keys remain strings when rendered,
but cross-filter and drill-filter paths still convert them to numbers, sending
a value different from the selected header.
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%2F44352&comment_hash=b0b4f48911a0ee9822f20386ddf3831dd0dd6ba9702eb0d9a8c297566bee5f91&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44352&comment_hash=b0b4f48911a0ee9822f20386ddf3831dd0dd6ba9702eb0d9a8c297566bee5f91&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]