Skip to content

fix: replace bare assert with graceful handler in _guess_method (#1614)#1837

Open
codegeek03 wants to merge 1 commit intohttpie:masterfrom
codegeek03:master
Open

fix: replace bare assert with graceful handler in _guess_method (#1614)#1837
codegeek03 wants to merge 1 commit intohttpie:masterfrom
codegeek03:master

Conversation

@codegeek03
Copy link
Copy Markdown

Fixes #1614
When a user passes optional flags between the HTTP method and URL (e.g. http POST --auth-type bearer --auth $TOKEN https://example.org), argparse can assign the URL to request_items instead of url. The existing assert not self.args.request_items then throws a raw, unhelpful AssertionError.
This PR replaces the bare assert with explicit handling:

If url is None and request_items is non-empty, promote request_items[0] to url (recovery path).
If both url and request_items are set, emit a proper self.error(...) message with usage guidance.

A regression test is added for the recovery path.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssertionError when trying to POST with bearer auth

1 participant