Skip to content

Empty or blank required UUID header validation results in 200 response status #23939

Closed
@maxdewil

Description

@maxdewil

Affects: Spring MVC 5.1.9.RELEASE


Hi,

My REST API takes as input a mandatory X-Request-ID header that is transformed to a UUID object.

So my REST controller method has this parameter:
@RequestHeader(value="X-Request-ID", required=true) UUID xRequestID

However, if the X-Request-ID HTTP header:

  • is absent : 400 Bad Request (OK)
  • is empty (i.e. the empty string) : 200 OK (NOK, should be 400)
  • is blank (i.e. a string with whitespace only) : 200 OK (NOK, should be 400)
  • is not a UUID (for instance "foobar") : 400 Bad Request (OK)

It seems that the problem comes from:

  1. 'is empty' case: StringToUUIDConverter returns null
  2. 'is blank' case: StringToUUIDConverter fails, then Spring MVC defaults to UUIDEditor that returns null.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions