Skip to content

--assert-status accepts codes that can never match (-1, 999) #93

Description

@korya

Problem

--assert-status accepts any integer, including values no HTTP response can carry. The assertion is then guaranteed to fail at runtime with exit 93.

Reproduction

$ http-assert --assert-status 999 http://127.0.0.1:8099/ok
- status: expected 999, got 200 ("200 OK")
$ echo $?
93

$ http-assert --assert-status -1 http://127.0.0.1:8099/ok
- status: expected -1, got 200 ("200 OK")
$ echo $?
93

Why it matters

An unsatisfiable status is a typo in the invocation, not a fact about the service, so 93 sends the wrong signal: a CI job reading the exit code concludes the service is broken. This is the distinction #86 set out to make.

The tool already validates the other numeric flags at invocation time, and does it well:

$ http-assert --retry -3 ...
Error: Invalid value for --retry flag: -3; it counts retries, so the smallest meaningful value is 0

--assert-status is the outlier.

Suggested fix

Reject values outside 100–599 with exit 71, in the style of the --retry and --max-redirs messages.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions