-
Bug
-
Resolution: Unresolved
-
Normal
-
None
-
None
-
None
-
False
-
-
False
-
subs-swatch-lightning
-
-
When invalid enum values are passed as query parameters (e.g., granularity=HOURLLY), the API returns HTTP 404 Not Found instead of the more appropriate HTTP 400 Bad Request.
Current Behavior:
- Invalid enum query parameters cause JAX-RS parameter binding to fail at the framework level
- Framework treats this as "endpoint not found" and returns 404
- Example: GET /api/rhsm-subscriptions/v1/capacity/products/ROSA/Cores?granularity=HOURLLY → 404
Expected Behavior:
- Invalid parameter values should return HTTP 400 Bad Request with a clear error message
- Example: GET /api/rhsm-subscriptions/v1/capacity/products/ROSA/Cores?granularity=HOURLLY → 400 with message "Invalid granularity: HOURLLY"
Affected Services:
- swatch-contracts (Quarkus)
- swatch-tally (Spring Boot)
- Any service using direct enum types for query parameters
Root Cause:
JAX-RS/Resteasy automatically binds query parameters to enum types. When binding fails, the framework returns 404 before the method is invoked.
The /v1/instances/products endpoint correctly returns 400 for invalid metric_id because it accepts a String parameter and manually converts it with explicit error handling.
Proposed fix by jcarvaja@redhat.com on slack
Acceptance Criteria:
- Invalid enum query parameter values return HTTP 400
- Error response includes clear message indicating which parameter is invalid and what value was provided
- Valid enum values continue to work as expected
- Add a test in spring boot to validate the chnage