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


##########
superset/middleware/legacy_prefix_redirect.py:
##########
@@ -211,6 +227,22 @@ def __call__(
             return self.wsgi_app(environ, start_response)
 
         canonical_after_strip = candidate[len(_LEGACY_PREFIX) :] or "/"
+
+        # Special case: /superset/sql/<database_id>/ has no 1:1 path mapping β€”
+        # Database.sql_url migrated to the query-string shape 
/sqllab/?dbid=<id>.
+        # Redirect it explicitly (numeric id only) so legacy SQL Lab deep links
+        # survive one release cycle instead of hard-404ing.
+        if sql_match := _LEGACY_SQL_RE.match(canonical_after_strip):
+            if method != "GET":
+                # The old /superset/sql/<id>/ route was GET-only; a 308 would
+                # have the client retry-POST against /sqllab/ β†’ 405. Emit 410.
+                return _response_with_location(410, None)(environ, 
start_response)
+            location = 
f"{self.app_root_prefix}/sqllab/?dbid={sql_match.group(1)}"
+            if query_string := environ.get("QUERY_STRING", ""):
+                # location already carries ?dbid=<id>; merge with & not ?.
+                location = f"{location}&{query_string}"
+            return _response_with_location(308, location)(environ, 
start_response)

Review Comment:
   **Suggestion:** Add explicit type annotations for the newly introduced local 
values in this SQL legacy-redirect branch (including the regex match result and 
query string handling) to comply with the type-hint requirement. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? πŸ€” </b></summary>
   
   The new code introduces local values via walrus assignments (`sql_match` and 
`query_string`) without explicit type annotations, which matches the rule’s 
requirement to flag new or modified Python code that omits type hints on 
annotatable variables.
   </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=d964f3b36c2741be990161a48b9bb9dd&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=d964f3b36c2741be990161a48b9bb9dd&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/middleware/legacy_prefix_redirect.py
   **Line:** 235:244
   **Comment:**
        *Custom Rule: Add explicit type annotations for the newly introduced 
local values in this SQL legacy-redirect branch (including the regex match 
result and query string handling) to comply with the type-hint requirement.
   
   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%2F41759&comment_hash=d156ded3a6fb79413db03399e5772e3d4fb2fac9b57a3373ef021fc74ee06321&reaction=like'>πŸ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41759&comment_hash=d156ded3a6fb79413db03399e5772e3d4fb2fac9b57a3373ef021fc74ee06321&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