rusackas commented on code in PR #41759:
URL: https://github.com/apache/superset/pull/41759#discussion_r3538248851
##########
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:
Under `APPLICATION_ROOT=/superset` the legacy prefix and the app root
collide, which is exactly why the shim no-ops there (the `_enabled` gate).
Redirecting `/sql/<id>/` in that shape would reintroduce the ambiguity I'm
deliberately avoiding, so this stays an intentional gap for that degenerate
config.
--
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]