codeant-ai-for-open-source[bot] commented on code in PR #42144:
URL: https://github.com/apache/superset/pull/42144#discussion_r3624304741


##########
superset/mcp_service/dataset/schemas.py:
##########
@@ -838,9 +861,12 @@ class QueryDatasetRequest(QueryCacheControl):
     time_range: str | None = Field(
         default=None,
         description=(
-            "Time range filter (e.g. 'Last 7 days', 'Last month', "
-            "'2024-01-01 : 2024-12-31'). Requires a temporal column "
-            "on the dataset."
+            "Time range filter. Use Superset relative shorthands like "
+            "'Last 7 days', 'Last month', 'Last year', 'Last quarter', "
+            "'this week', 'previous calendar year', or an ISO-8601 range "
+            "like '2024-01-01 : 2024-12-31'. Requires a temporal column "
+            "on the dataset. Do NOT use bracket shorthands like '[year]' "
+            "or '[quarter]' โ€” use 'Last year' / 'Last quarter' instead."

Review Comment:
   **Suggestion:** The `time_range` field description says bracket shorthands 
should not be used, but the new validator explicitly accepts and normalizes 
them; this documentation mismatch can cause clients to treat valid inputs as 
invalid and diverges from actual runtime behavior. Update the description to 
state that bracket shorthands are accepted and normalized (or remove 
normalization if they are truly unsupported). [comment mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - Warning-only: documentation discourages patterns that runtime tolerates.
   - Warning-only: no failure; bracket shorthands work as normalized.
   - Warning-only: suggestion targets guidance, not functional behavior.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction โœ… </b></summary>
   
   ```mdx
   1. Open `superset/mcp_service/dataset/schemas.py` and locate 
`QueryDatasetRequest` at
   lines 833โ€“910; its `time_range` field definition and description are at 
lines 861โ€“869.
   
   2. Read the description text at lines 864โ€“869, which explicitly instructs: 
"Do NOT use
   bracket shorthands like '[year]' or '[quarter]' โ€” use 'Last year' / 'Last 
quarter'
   instead."
   
   3. In the same file, inspect the `_BRACKET_SHORTHAND_TO_TIME_RANGE` mapping 
at lines
   821โ€“830 and the `normalize_time_range` field validator at lines 894โ€“901; 
this validator
   trims the input, lowercases it, and normalizes bracket shorthands found in 
the mapping.
   
   4. Instantiate `QueryDatasetRequest` in a Python environment by importing it 
from
   `superset.mcp_service.dataset.schemas` and passing `time_range="[year]"`; 
Pydantic applies
   `normalize_time_range`, replacing `"[year]"` with `"Last year"` 
successfully. This shows
   the code is intentionally tolerant of bracket shorthands, while the 
description
   discourages their deliberate use. The discrepancy is about recommended 
usage, not a
   functional bug.
   ```
   </details>
   
   [![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=ea83c3234c054628a35b53a7df7401c0&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=ea83c3234c054628a35b53a7df7401c0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/dataset/schemas.py
   **Line:** 864:869
   **Comment:**
        *Comment Mismatch: The `time_range` field description says bracket 
shorthands should not be used, but the new validator explicitly accepts and 
normalizes them; this documentation mismatch can cause clients to treat valid 
inputs as invalid and diverges from actual runtime behavior. Update the 
description to state that bracket shorthands are accepted and normalized (or 
remove normalization if they are truly unsupported).
   
   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%2F42144&comment_hash=02c8f23dd33cf3411a47b0201b4954de6f41b0fb220882cbef75e6edcba7d822&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42144&comment_hash=02c8f23dd33cf3411a47b0201b4954de6f41b0fb220882cbef75e6edcba7d822&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]

Reply via email to