Skip to content

Bugfix/unmatched path returns 404#77

Merged
weited merged 3 commits into
mainfrom
bugfix/unmatched-path-returns-404
Jun 2, 2026
Merged

Bugfix/unmatched path returns 404#77
weited merged 3 commits into
mainfrom
bugfix/unmatched-path-returns-404

Conversation

@weited
Copy link
Copy Markdown
Collaborator

@weited weited commented Jun 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings June 1, 2026 09:12
Copy link
Copy Markdown

Copilot AI left a comment

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 addresses incorrect error handling for unmatched routes (returning 500 instead of 404) and introduces request-path normalization so trailing slashes don’t break handler resolution under Spring Boot 3 (e.g., when a proxy appends /).

Changes:

  • Add a NoResourceFoundException handler in GlobalExceptionHandler to return 404 for unmapped paths/resources.
  • Introduce TrailingSlashNormalizationFilter to strip trailing slashes for application endpoints while excluding framework-managed paths (springdoc + actuator).
  • Add/extend tests to assert 404 behavior for unmatched paths and validate trailing-slash normalization behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/main/java/au/org/aodn/oceancurrent/exception/GlobalExceptionHandler.java Adds a dedicated 404 handler for NoResourceFoundException to avoid the catch-all mapping these cases to 500.
src/main/java/au/org/aodn/oceancurrent/configuration/TrailingSlashNormalizationFilter.java Adds a highest-precedence filter to normalize trailing slashes while skipping swagger/api-docs/webjars/actuator routes.
src/test/java/au/org/aodn/oceancurrent/controller/ImageMetadataControllerTest.java Adds a regression test ensuring unmatched paths return 404.
src/test/java/au/org/aodn/oceancurrent/configuration/TrailingSlashNormalizationFilterTest.java Adds unit tests for trailing-slash normalization and excluded paths.

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

@weited weited merged commit 78ba026 into main Jun 2, 2026
1 check passed
@weited weited deleted the bugfix/unmatched-path-returns-404 branch June 2, 2026 03: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