Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-13611 Reuse shared proxy header handling for Content Viewer #9134

Closed
wants to merge 1 commit into from

Conversation

exceptionfactory
Copy link
Contributor

Summary

NIFI-13611 Refactors the ContentViewerController to use the shared RequestUriBuilder from nifi-web-servlet-shared to prepare the data reference URI. This avoids duplicate code and ensures consistent handling when NiFi is running behind a reverse proxy server.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 21

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@mcgilman
Copy link
Contributor

mcgilman commented Aug 5, 2024

Will review...

// this is necessary for scenario's where the NiFi instance is behind a proxy running a different scheme
refUriBuilder.scheme(request.getScheme());
final URI inputRefUri = UriBuilder.fromUri(ref).build();
final URI dataUri = RequestUriBuilder.fromHttpServletRequest(request).path(inputRefUri.getPath()).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes do not work when clustered and behind a proxy. The incoming ref is the user facing URI. The previous behavior converted that URI into an "internal" URI so that a node could directly GET the content from another node in the cluster.

Interestingly, this behavior in this PR exposes an issue in handling the response of this GET because the response does not contain a content-disposition header and fails with an NPE.

3296 [APP] 2024-08-05 13:20:45,807 WARN [NiFi Web Server-191] org.apache.nifi.web.ContentViewerController Content retrieval failed
3297 java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "headerValue" is null
3298     at org.springframework.http.ContentDisposition.tokenize(ContentDisposition.java:454)
3299     at org.springframework.http.ContentDisposition.parse(ContentDisposition.java:344)
3300     at org.apache.nifi.web.StandardNiFiContentAccess.getContent(StandardNiFiContentAccess.java:120)
3301     at org.apache.nifi.web.ContentViewerController.doGet(ContentViewerController.java:95)
3302     at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
3303     at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @mcgilman, I see the issue now with the URL changes for clustered requests. I will correct that issue and review the Content-Disposition handling.

@exceptionfactory
Copy link
Contributor Author

Based on a separate discussion, I am going to close this pull request. With potential pending changes to the handling of custom content viewing, making incremental changes to the current Controller class is not necessary.

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