Skip to content

Unsupported scheme and empty URL exit 92 though no request was attempted #94

Description

@korya

Problem

A URL with an unsupported scheme, or an empty URL, exits 92 ("the request produced no usable response") even though no request was ever attempted — Go rejects the scheme in the client, before any socket is opened.

Reproduction

$ http-assert --assert-ok ftp://example.com/x
Error: Cannot perform request: failed to send request:
- Get "ftp://example.com/x": unsupported protocol scheme "ftp"
$ echo $?
92

$ http-assert --assert-ok ""
Error: Cannot perform request: failed to send request:
- Get "": unsupported protocol scheme ""
$ echo $?
92

Why it matters

--help defines the codes as:

71   the invocation was rejected; no request was attempted
92   the request produced no usable response

Both cases meet the definition of 71 exactly. Reporting them as 92 tells a CI job the network or the service is at fault when the caller mistyped a URL — the confusion #86 was written to remove.

For contrast, a scheme-less URL already gets this right:

$ http-assert --assert-ok 127.0.0.1:8099/ok
Error: Cannot create request 'GET 127.0.0.1:8099/ok': parse "127.0.0.1:8099/ok": first path segment in URL cannot contain colon
$ echo $?
71

Other

The empty-URL path also renders poorly: FAILED: GET (HTTP/1.1) (two spaces) with an empty Host: in the dump.

Suggested fix

Validate the scheme when the request is built, alongside the existing URL parse check, so both exit 71.

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