You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sadpandajoe (via GitHub)" <gi...@apache.org> on 2026/09/16 16:05:45 UTC

[PR] fix(time-format): stop reading short digit-only strings as epoch offsets [superset]

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

   ### SUMMARY
   
   Fast follow to #43909, which fixed only the bare four-digit-year case of
   `stringifyTimeInput()` (`superset-frontend/packages/superset-ui-core/src/time-format/utils/stringifyTimeInput.ts`).
   Every other digit-only string was still read as an epoch offset or handed to
   an engine-specific `Date` parser, so it resolved to a moment near 1970 (or,
   for the pivot table, near 1970 even earlier — see below) and rendered wrong.
   This closes #43847's second reported case; the four-digit-year case was
   already covered by #43909.
   
   **Core parser.** `stringifyTimeInput` now only treats a digit-only string as
   an epoch-millisecond timestamp once it has at least 10 digits — long enough
   to plausibly be one. A bare four-digit string is still read as an ISO
   8601 year. Any other digit-only string — a `YYYYMMDD` key like `"20260903"`,
   a `YYYYMM` key like `"202609"`, or a small integer like `"5"` or `"0"` — is
   returned unchanged rather than handed to `new Date(value)`: V8's legacy
   parser reads those through an implementation-specific fallback (`"202609"`
   becomes the year 202609, `"5"` becomes May 2001, `"0"` becomes January 2000),
   so leaving it to the Invalid-Date/NaN fallback doesn't hold for every length
   and would still silently produce a wrong date.
   
   **Pivot table.** `TableRenderers.tsx`'s `toDateFormatterInput` never reached
   the core fix at all: it coerced every finite numeric string to a `Number`
   before formatting, so a `"20260903"` pivot header rendered as `1970-01-01`
   independently of the core parser. Its coercion now only fires for the same
   10+-digit epoch case; date keys and small integers stay strings and are
   handed to the (now-fixed) shared formatter to resolve.
   
   | input | before this PR | after |
   | --- | --- | --- |
   | `"20260903"` | `1970-01-01T05:37:40.903Z` | `"20260903"` (unchanged) |
   | `"202609"` | `Date` legacy-parses it as the year 202609 | `"202609"` (unchanged) |
   | `"5"` | `Date` legacy-parses it as May 2001 | `"5"` (unchanged) |
   | `"2017"` | `2017-01-01T00:00:00.000Z` (already fixed by #43909) | unaffected |
   | `"1487071353000"` | `2017-02-14T11:22:33.000Z` | unaffected |
   | Pivot table header `"20260903"` | rendered `1970-01-01` | rendered `20260903` unchanged |
   
   Out of scope, deliberately: epoch-*seconds* strings (e.g. a 10-digit value
   like `"1487071353"`) are still read as epoch milliseconds, a separate,
   pre-existing ambiguity noted on #43847 but not part of its reported
   symptoms.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — not UI-visible without a running Superset instance in this
   environment; no screenshot was captured.
   
   ### TESTING INSTRUCTIONS
   
   ```
   cd superset-frontend
   npx jest packages/superset-ui-core/test/time-format plugins/plugin-chart-table plugins/plugin-chart-ag-grid-table plugins/plugin-chart-pivot-table
   ```
   
   By hand: put a string column of `YYYYMMDD`-style values (e.g. `20260903`) in
   a Table chart, set a D3 time format such as `%Y-%m-%d` on it under Customize
   → Customize columns; on `master` every cell renders `1970-01-01`, here the
   raw value is shown unchanged. For the pivot table, use the same kind of
   column as a row/column header with a date formatter configured — on `master`
   the header renders `1970-01-01`, here it renders `20260903` unchanged.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #43847
   - [ ] 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
   


-- 
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(time-format): stop reading short digit-only strings as epoch offsets [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44352:
URL: https://github.com/apache/superset/pull/44352#issuecomment-5700990764

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44352?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 80.25%. Comparing base ([`b1380cf`](https://app.codecov.io/gh/apache/superset/commit/b1380cf43d2cabdd0f5bde362788d071455409f1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`93c3e47`](https://app.codecov.io/gh/apache/superset/commit/93c3e4709ad02803ae25e45a4d5fa0344fc977bc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 23 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #44352      +/-   ##
   ==========================================
   - Coverage   80.26%   80.25%   -0.01%     
   ==========================================
     Files        2927     2927              
     Lines      173238   173240       +2     
     Branches    40169    40167       -2     
   ==========================================
   - Hits       139045   139042       -3     
   - Misses      31601    31606       +5     
     Partials     2592     2592              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/44352/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/44352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `75.67% <100.00%> (-0.01%)` | :arrow_down: |
   
   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/44352?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(time-format): stop reading short digit-only strings as epoch offsets [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #44352:
URL: https://github.com/apache/superset/pull/44352#issuecomment-5701302523

   🎪 [Showtime](https://github.com/mistercrunch/superset-showtime) is building environment on [GHA](https://github.com/apache/superset/actions/runs/35121089902) for [93c3e47](https://github.com/apache/superset/commit/93c3e47)


-- 
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(time-format): stop reading short digit-only strings as epoch offsets [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44352:
URL: https://github.com/apache/superset/pull/44352#issuecomment-5700607491

   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(time-format): stop reading short digit-only strings as epoch offsets [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 #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`
   
   [![Use CodeAnt Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](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) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](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: 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(time-format): stop reading short digit-only strings as epoch offsets [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe merged PR #44352:
URL: https://github.com/apache/superset/pull/44352


-- 
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(time-format): stop reading short digit-only strings as epoch offsets [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44352:
URL: https://github.com/apache/superset/pull/44352#issuecomment-5706444657

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation of `toDateFormatterInput` in `superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx` was overly aggressive in coercing numeric strings to numbers, which caused short date keys (like YYYYMMDD) to be incorrectly treated as epoch timestamps.
   
   The fix implemented in the PR (as seen in the diff) correctly updates `toDateFormatterInput` to only coerce strings that are at least 10 digits long, which is the minimum length to plausibly represent an epoch timestamp in milliseconds. This ensures that shorter numeric strings, such as date keys, are passed through as strings and handled correctly by the shared `stringifyTimeInput` utility.
   
   Since the fix is already present in the provided PR diff, no further action is required for this specific issue. I have checked the PR comments, and there are no other pending review comments to address.
   
   **superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx**
   ```
   const toDateFormatterInput = (value: unknown): unknown =>
     typeof value === 'string' && /^-?\d{10,}$/.test(value.trim())
   ```


-- 
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(time-format): stop reading short digit-only strings as epoch offsets [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44352:
URL: https://github.com/apache/superset/pull/44352#issuecomment-5700676276

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 93c3e4709ad02803ae25e45a4d5fa0344fc977bc |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6aaabe5aab7e5300086eae2f |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-44352--superset-docs-preview.netlify.app](https://deploy-preview-44352--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQ0MzUyLS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.dvvzl1Y-1MDVebk1jSZ0GsfEAVaQDsdBS8plNJj7Dms)<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#q1YqKMrPLShRslJS0lFKKkrMS84AsktzSooSi1NLdNMyK3RNjC1MzIGyKakFOfmVnilAebPExMSkVFMgYZ5qamxgYGBhlpqYapSmVAsA) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-44352--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