Skip to content

Return not found for unresolved function routes - #4274

Open
avsan wants to merge 1 commit into
spring-cloud:mainfrom
avsan:fix/gh-4170-function-not-found-status
Open

Return not found for unresolved function routes#4274
avsan wants to merge 1 commit into
spring-cloud:mainfrom
avsan:fix/gh-4170-function-not-found-status

Conversation

@avsan

@avsan avsan commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Return 404 Not Found when a default WebMVC function route cannot resolve a target function.

Previously, an unmatched request could fall through to Spring Cloud Function's RoutingFunction and fail during request processing, resulting in 415 Unsupported Media Type instead of the expected 404 Not Found.

The change preserves the existing RoutingFunction fallback when a routing target, default route handler, or MessageRoutingCallback is available.

Changes

  • Return 404 Not Found when no function routing target can be resolved.
  • Preserve the existing Spring Cloud Function RoutingFunction fallback behavior.
  • Preserve automatic function routing for valid functions.
  • Add regression coverage for unmatched routes.
  • Add coverage verifying automatically configured function routes continue to work.

Testing

Before the fix:

GET /does-not-exist

Expected: 404 NOT_FOUND
Actual: 415 UNSUPPORTED_MEDIA_TYPE

After the fix:

GET /does-not-exist404 NOT_FOUND

Validation completed:

  • FunctionHandlerConfigTests: 5 tests passed.
  • DefaultRouteFunctionHandlerTests: 5 tests passed.
  • Combined focused tests: 10 tests passed.
  • git diff --check: clean.

A later full Maven reactor validation attempt was blocked before compilation because the upstream spring-cloud-stream-dependencies:5.1.0-SNAPSHOT BOM could not be resolved from the Spring snapshot repository.

Fixes #4170

Avoid invoking the Spring Cloud Function routing function when an
unmatched Gateway function route has no routing target, default route
handler, or routing callback.

This prevents unmatched requests from failing during request body
conversion and returns 404 Not Found instead, while preserving default
function routing behavior.

Add regression coverage for unmatched routes and automatic function
routing.

See spring-cloudgh-4170

Signed-off-by: Abhishek Kumar Pandey <abhishekrajabca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4.3.x when using spring cloud functions no longer returns 404 and exceptions forwarded to /error result in a AopConfigException

2 participants