During testing of the Admin API for creating Open Offers, we hit a strange validation failure. The request payload looked correct — all required fields were present, including offerType: "OPEN_OFFER". Authentication and security checks passed, and the request was logged by our filters.

Yet, before even reaching the controller, Spring rejected the request with a validation error:

Field error in object 'offerTypeOpenCreateAdminRequest' on field 'offerType':
rejected value [null]; must not be null

So we had a paradox: the frontend sent "offerType": "OPEN_OFFER", but by the time the DTO was bound inside the backend, that value was gone and seen as null.

This immediately pointed us toward a deeper issue in the deserialization + validation layer, not in business logic or controller code.

1. Problem Statement

When calling the Admin API endpoint:

POST /api/v1/admin/offers/open-offers

with a payload such as:

{
  "offerType": "OPEN_OFFER",
  "title": "Test",
  "date": {
    "stalkDate": "2025-10-05",
    "expiryDate": "2025-10-09"
  },
  "finance": {
    "totalAmount": "10000"
  },
  "employeeId": "EMPLOYEE_UUID_PLACEHOLDER",
  "accountManagerId": "ACCOUNT_MANAGER_UUID_PLACEHOLDER",
  "organizationId": "ORGANIZATION_UUID_PLACEHOLDER",
  "userId": "USER_UUID_PLACEHOLDER"
}

the backend rejected the request before entering the controller, returning:

Validation failed for argument [0] ...
Field error in object 'offerTypeOpenCreateAdminRequest' on field 'offerType':
rejected value [null]; default message [must not be null]


2. Logs Observed

Spring Validation Failure

2025-10-03 13:04:31 [http-nio-8080-exec-3] ERROR c.s.f.c.l.service.LoggingService
[GlobalExceptionHandler]: Validation failed for argument [0]
in public org.springframework.http.ResponseEntity...
Field error in object 'offerTypeOpenCreateAdminRequest' on field 'offerType':
rejected value [null]; codes [NotNull.offerTypeOpenCreateAdminRequest.offerType,NotNull.offerType];
default message [must not be null]

Important Findings