Skip to content

[filebrowser] fix: preserve OFS File Browser routes across login redirects - #4351

Open
smengcl wants to merge 1 commit into
cloudera:masterfrom
smengcl:fix/hue-ofs-login-redirect
Open

[filebrowser] fix: preserve OFS File Browser routes across login redirects#4351
smengcl wants to merge 1 commit into
cloudera:masterfrom
smengcl:fix/hue-ofs-login-redirect

Conversation

@smengcl

@smengcl smengcl commented Jul 20, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

Fixes login redirects for Hue File Browser deep links containing OFS paths: #4350

When an unauthenticated user opens an OFS URL such as:

/hue/filebrowser/view=ofs%3A%2F%2Fom%2Fvolume%2Fbucket%2Ffile.txt

signing in previously redirected them to a corrupted view%3Dofs://... route. Hue then treated the route as an HDFS path and displayed the misleading error:

The HDFS REST service is not available.

Root cause

request.get_full_path() already escapes characters in the path. Passing that result through quote() encoded the existing percent sign again:

request.path:            /hue/filebrowser/view=ofs://...
request.get_full_path(): /hue/filebrowser/view%3Dofs://...
quote(...):              /hue/filebrowser/view%253Dofs%3A//...

After authentication, one encoded layer remained and changed the File Browser route.

Proposed Fix

Build the redirect target from:

  • decoded request.path
  • the original raw QUERY_STRING

The completed target is then quoted exactly once. This preserves the existing HTTP 302 login flow while retaining OFS route delimiters and already-encoded query values.

How was this patch tested?

  • Added regression coverage for:
    • Preserving view=ofs://... across an unauthenticated login redirect.
    • Preserving an encoded query value such as search=a%26b.
  • Additional verification
    • Python compilation passed.
    • Source assertions passed.
    • Verified end-to-end using gethue/hue:20250101-140101 with an Apache Ozone 2.1.1 cluster and Ozone HttpFS.
    • Confirmed that logout → OFS deep link → login opens the requested Ozone file.
    • Full Hue pytest/pylint execution was not available in the local environment.

Copilot AI review requested due to automatic review settings July 20, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Hue login redirects for deep links whose route data is embedded in the path (not the query string), specifically File Browser OFS routes like .../filebrowser/view=ofs%3A%2F%2F..., by avoiding double-encoding introduced by request.get_full_path() + quote().

Changes:

  • Add _get_request_target() helper to build redirect targets from decoded request.path plus the raw QUERY_STRING, then quote once for the next= parameter.
  • Update the login redirect construction in RequireLoginEverywhereMiddleware.process_view() to use the new helper.
  • Add regression tests ensuring OFS route delimiters and already-encoded query values are preserved across login redirects.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
desktop/core/src/desktop/middleware.py Refactors redirect target generation to prevent route corruption by constructing a stable path+query target before quoting.
desktop/core/src/desktop/require_login_test.py Adds regression coverage for OFS deep link and encoded query-string preservation through the login redirect.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread desktop/core/src/desktop/middleware.py
@smengcl
smengcl force-pushed the fix/hue-ofs-login-redirect branch from 25631a6 to e56e6ec Compare July 20, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants