Found by code inspection
💥 Actual behavior
When calling DELETE /api/v1/fleet/scripts/batch/{id} (cancel) or GET /api/v1/fleet/scripts/batch/{id}/summary (status) with a nonexistent batch execution ID, the server returns HTTP 200 with an empty response body instead of HTTP 404.
The root cause is in server/service/scripts.go. After ListBatchScriptExecutions returns successfully with an empty list, the code calls ctxerr.Wrap(ctx, err, "...") where err is nil (from the successful list call). Since ctxerr.Wrap returns nil when the cause is nil, the function returns nil (success) instead of a not-found error.
🛠️ To fix
Replace ctxerr.Wrap(ctx, err, "get batch script status") with a proper not-found error at both locations (server/service/scripts.go). For example:
return ctxerr.Wrap(ctx, notFoundError{}, "batch execution not found")
🧑💻 Steps to reproduce
These steps:
- Authenticate as a global admin via
POST /api/v1/fleet/login
- Call
GET /api/v1/fleet/scripts/batch/99999999/summary (any nonexistent batch execution ID)
- Observe HTTP 200 with empty/nil response instead of HTTP 404
- Similarly, call
DELETE /api/v1/fleet/scripts/batch/99999999 and observe HTTP 200
🕯️ More info (optional)
Found by code inspection
💥 Actual behavior
When calling
DELETE /api/v1/fleet/scripts/batch/{id}(cancel) orGET /api/v1/fleet/scripts/batch/{id}/summary(status) with a nonexistent batch execution ID, the server returns HTTP 200 with an empty response body instead of HTTP 404.The root cause is in
server/service/scripts.go. AfterListBatchScriptExecutionsreturns successfully with an empty list, the code callsctxerr.Wrap(ctx, err, "...")whereerris nil (from the successful list call). Sincectxerr.Wrapreturns nil when the cause is nil, the function returns nil (success) instead of a not-found error.🛠️ To fix
Replace
ctxerr.Wrap(ctx, err, "get batch script status")with a proper not-found error at both locations (server/service/scripts.go). For example:🧑💻 Steps to reproduce
These steps:
POST /api/v1/fleet/loginGET /api/v1/fleet/scripts/batch/99999999/summary(any nonexistent batch execution ID)DELETE /api/v1/fleet/scripts/batch/99999999and observe HTTP 200🕯️ More info (optional)