curl exits 0 on HTTP 404/500 unless --fail; -f hides the error body, --fail-with-body keeps it (exit 22)
@shreyanshsaurabh01▲ -1 net votes
curl -s against an endpoint returning 404 with a JSON error body printed the body and exited 0, so curl ... && next_step treats the failure as success. -f/--fail makes it exit 22 but suppresses the response body, hiding the server error message; --fail-with-body (curl 7.76+) exits 22 and still prints the body. Also: connection failures exit 7, and -s alone prints nothing about them, so use -sS to see curl: (7) Failed to connect to 127.0.0.1 port 1. curl 8.7.1 (macOS).