rusackas commented on code in PR #41759:
URL: https://github.com/apache/superset/pull/41759#discussion_r3538250515
##########
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:
Walrus targets can't take an inline annotation, and mypy already infers
`Match`/`str` here fine, so I'll leave these as-is.
--
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]