GET /device/{token}/software returns HTTP 400 instead of 422 when CVSS/exploit params are sent without vulnerable=true
Fleet versions
- Discovered: orbit-v1.57.0-460-ge2ca3120ee (main, 2026-07-13)
- Reproduced: orbit-v1.57.0-460-ge2ca3120ee
Web browser and operating system: API tested via fleetctl CLI on macOS 26.5.2
💥 Actual behavior
GET /device/{token}/software returns HTTP 400 when min_cvss_score, max_cvss_score, or exploit are sent without vulnerable=true:
HTTP/1.1 400 Bad Request { "message": "...", "errors": [ { "name": "query", "reason": "min_cvss_score, max_cvss_score, and exploit can only be provided with vulnerable=true" } ] }
🛠️ Expected behavior
Per the test plan and Fleet's own error type conventions, this validation error should return HTTP 422 Unprocessable Entity. The error is raised via fleet.NewInvalidArgumentError in server/datastore/mysql/software.go, which is explicitly designed to return 422 — the invalidArgWithStatusError wrapper in server/fleet/errors.go even carries the comment "422 is the default code for invalid args." The EncodeError function in server/platform/endpointer/transport_error.go maps validationErrorInterface (which InvalidArgumentError satisfies) to http.StatusUnprocessableEntity by default.
The enforcement is correct — the request is rejected with the right error message — but the status code is semantically wrong. HTTP 400 means "malformed request"; HTTP 422 means "valid request with semantically invalid parameters," which is exactly what this case represents.
🧑💻 Steps to reproduce
- [ ] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
- [x] Describe the workflow that led to the error, but have not yet been reproduced in multiple Fleet instances.
- Have a Fleet Premium instance running on main.
- Obtain a valid device token from host_device_auth for any enrolled host, or use any enrolled host's Fleet Desktop token.
- Send any of the following requests (CVSS/exploit param without vulnerable=true): GET /api/latest/fleet/device/{token}/software?min_cvss_score=9.0 GET /api/latest/fleet/device/{token}/software?max_cvss_score=6.9 GET /api/latest/fleet/device/{token}/software?exploit=true
- Observe the response is HTTP 400.
- Expected response is HTTP 422.
🕯️ More info
The validation is performed in server/datastore/mysql/software.go (ListHostSoftware, line ~5096) and server/datastore/mysql/software_titles.go (ListSoftwareTitles, line ~246), both via fleet.NewInvalidArgumentError. That type satisfies validationErrorInterface in the endpointer's error encoder, which should route to the 422 branch — but the observed status is 400. The discrepancy suggests the error type information is being lost somewhere in the wrapping chain between the datastore and the HTTP encoder.
The same behavior likely affects GET /api/latest/fleet/hosts/{id}/software (the admin-facing host software endpoint) since it calls the same datastore function.
Could not reproduce
Errors lost in code, Fleet now finds clarity, Truth in 422.