Caddy : v2.7.4 + (master)
OS: Ubuntu 22.04
Module: API
Issue:
When I delete a non-existing listener, Caddy returns 200 instead of 4xx.
Reproduce:
- caddy run (no config)
- Add a route:
hello.json
{
"apps": {
"http": {
"servers": {
"example": {
"listen": [":2015"],
"routes": [
{
"handle": [
{
"handler": "static_response",
"body": "Hello, world!"
}
]
}
]
}
}
}
}
}
curl localhost:2019/load -H "Content-Type: application/json" -d @hello.json
- Validate the route:
curl localhost:2019/config/
{"apps":{"http":{"servers":{"example":{"listen":[":2015"],"routes":[{"handle":[{"body":"Hello, world!","handler":"static_response"}]}]}}}}}
- Delete the route, providing an invalid parameter - foo:
curl -I -X DELETE "http://localhost:2019/config/apps/http/servers/foo"
HTTP/1.1 **200 OK** <---------------------- This is BAD
Date: Sat, 23 Sep 2023 16:03:58 GMT
Content-Length: 0
- Check deleted route again:
curl localhost:2019/config/
{"apps":{"http":{"servers":{"example":{"listen":[":2015"],"routes":[{"handle":[{"body":"Hello, world!","handler":"static_response"}]}]}}}}}
Actual Result:
As we see from Step 4, Caddy returns 200 on delete. However, my input was invalid and the route was NOT deleted.
This behavior results in issues for API integrators, because you never know whether the requested route was actually deleted or a misinput occured
Expected Result:
Caddy returns 4xx on invalid request
Caddy : v2.7.4 + (master)
OS: Ubuntu 22.04
Module: API
Issue:
When I delete a non-existing listener, Caddy returns
200instead of4xx.Reproduce:
hello.json{ "apps": { "http": { "servers": { "example": { "listen": [":2015"], "routes": [ { "handle": [ { "handler": "static_response", "body": "Hello, world!" } ] } ] } } } } }curl localhost:2019/load -H "Content-Type: application/json" -d @hello.jsoncurl localhost:2019/config/{"apps":{"http":{"servers":{"example":{"listen":[":2015"],"routes":[{"handle":[{"body":"Hello, world!","handler":"static_response"}]}]}}}}}curl -I -X DELETE "http://localhost:2019/config/apps/http/servers/foo"curl localhost:2019/config/{"apps":{"http":{"servers":{"example":{"listen":[":2015"],"routes":[{"handle":[{"body":"Hello, world!","handler":"static_response"}]}]}}}}}Actual Result:
As we see from Step 4,
Caddyreturns200on delete. However, my input was invalid and the route was NOT deleted.This behavior results in issues for API integrators, because you never know whether the requested route was actually deleted or a misinput occured
Expected Result:
Caddyreturns4xxon invalid request