codeant-ai-for-open-source[bot] commented on code in PR #43960: URL: https://github.com/apache/superset/pull/43960#discussion_r3948699376
########## superset-frontend/packages/superset-ui-core/src/time-format/utils/normalizeTimestamp.ts: ########## @@ -1,25 +1,28 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an + * or more agreed to in writing, software + * distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -export const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; +/** + * Timezone-aware strings carry an explicit UTC offset (`Z` or `ยฑhh:mm`). + * Rewriting them to a bare `Z` would relabel the wall-clock time as UTC, + * shifting the instant; they are returned untouched. Timezone names + * (`UTC`, `Europe/Helsinki`) are not valid ISO offsets and are still + * stripped the historic way. + */ +const TS_REGEX_TZ_AWARE = + /^(\d{4}-\d{2}-\d{2})[T\s](\d{2}:\d{2}:\d{2}\.?\d*)(?:Z|[+-]\d{2}:?\d{2})$/; +const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; Review Comment: **Suggestion:** `denormalizeTimestamp` imports `TS_REGEX` as a named export, but this declaration is not exported, causing the package TypeScript build to fail. [api mismatch] **Assessment:** ๐ด `Critical` ยท ๐ `Occurrence: Often` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=92f7dd6a36d44b58a1186cd11a2dc6d7&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=92f7dd6a36d44b58a1186cd11a2dc6d7&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/packages/superset-ui-core/src/time-format/utils/normalizeTimestamp.ts **Line:** 20:20 **Comment:** *Api Mismatch: `denormalizeTimestamp` imports `TS_REGEX` as a named export, but this declaration is not exported, causing the package TypeScript build to fail. 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%2F43960&comment_hash=8eb9fdb3e4082ca35928ee453ee5385db50bf0183793e913cc618b2816f2762a&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43960&comment_hash=8eb9fdb3e4082ca35928ee453ee5385db50bf0183793e913cc618b2816f2762a&reaction=dislike'>๐</a> ########## superset-frontend/packages/superset-ui-core/src/time-format/utils/normalizeTimestamp.ts: ########## @@ -1,25 +1,28 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an + * or more agreed to in writing, software + * distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -export const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; +/** + * Timezone-aware strings carry an explicit UTC offset (`Z` or `ยฑhh:mm`). + * Rewriting them to a bare `Z` would relabel the wall-clock time as UTC, + * shifting the instant; they are returned untouched. Timezone names + * (`UTC`, `Europe/Helsinki`) are not valid ISO offsets and are still + * stripped the historic way. + */ +const TS_REGEX_TZ_AWARE = + /^(\d{4}-\d{2}-\d{2})[T\s](\d{2}:\d{2}:\d{2}\.?\d*)(?:Z|[+-]\d{2}:?\d{2})$/; +const TS_REGEX = /(\d{4}-\d{2}-\d{2})[\sT](\d{2}:\d{2}:\d{2}\.?\d*).*/; export default function normalizeTimestamp(value: string): string { + if (TS_REGEX_TZ_AWARE.test(value)) { + return value; Review Comment: **Suggestion:** Preserving compact offsets such as `+0330` passes a non-standard date string to `new Date`, which can produce an invalid or inconsistent date across browsers. [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=8f49dab5ce9e4d30b6fcbd4f43ca0950&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=8f49dab5ce9e4d30b6fcbd4f43ca0950&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/packages/superset-ui-core/src/time-format/utils/normalizeTimestamp.ts **Line:** 23:24 **Comment:** *Api Mismatch: Preserving compact offsets such as `+0330` passes a non-standard date string to `new Date`, which can produce an invalid or inconsistent date across browsers. 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%2F43960&comment_hash=04e1a0d0c9d0ec27fac883f615b4a6bf96348ab12f1044e06ae5a21002a7cc43&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43960&comment_hash=04e1a0d0c9d0ec27fac883f615b4a6bf96348ab12f1044e06ae5a21002a7cc43&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]
