Skip to content

Conversation

@fwemaere
Copy link

@fwemaere fwemaere commented Feb 3, 2026

Context

When no API versioning is configured, calling
RequestMappingInfo#getMatchingCondition(ServerWebExchange exchange) results throws an exception.

Problem

The exception is thrown from VersionRequestCondition#getMatchingCondition.

When API versioning is disabled, the following line assumes that a version attribute is always present in the exchange:

ApiVersionHolder versionHolder =
        exchange.getRequiredAttribute(HandlerMapping.API_VERSION_ATTRIBUTE);

If no version has been resolved, this attribute is missing, which throws:

java.lang.IllegalArgumentException:
Required attribute 'org.springframework.web.reactive.HandlerMapping.apiVersion' is missing

VersionRequestCondition does not handle the case where API versioning is not configured.
It unconditionally expects HandlerMapping.API_VERSION_ATTRIBUTE to be present, even when no version is defined.

Fix

Checking version == null before makes VersionRequestCondition#getMatchingCondition resilient to the absence of API versioning by safely handling a null or missing API version attribute instead of throwing an exception.

Signed-off-by: François WEMAERE <32339136+fwemaere@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants