Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a warning for using option --ignore-stdin when request fails with content present in stdin #1525

Open
landure opened this issue Aug 29, 2023 · 0 comments
Labels
bug Something isn't working new Needs triage. Comments are welcome!

Comments

@landure
Copy link

landure commented Aug 29, 2023

Checklist

  • [ X] I've searched for similar issues.
  • [ X] I'm using the latest version of HTTPie.

Running environment

  • Ubuntu 22.04.3 LTS Jammy
  • bash 5.1-6ubuntu1
  • HTTPie 3.2.1 from https://packages.httpie.io/deb
  • jq
    (jq @ GitHub) 1.6-2.1ubuntu3.

Minimal reproduction code and steps

Install the software:

sudo apt install 'miller' jq'

The error occurred when interrogating Gandi Public API.

Set Gandi API Key:

gandi_api_key="<Gandi API key>"

Query Gandi API for all domains mailboxes:

while read -r 'domain'; do
  command https --body "https://api.gandi.net/v5/email/mailboxes/${domain}" \
    "Authorization: Apikey ${gandi_api_key}" 'per_page==250'
done < <( command https --body 'https://api.gandi.net/v5/domain/domains' \
    "Authorization: Apikey ${gandi_api_key}" 'per_page==250' |
  command jq '.[].fqdn' |
  command tr --delete '"' )

Current result

The first loop output is:

Bad Request

Expected result

The expected result:

Bad Request

Warning: stdin contents detected. Retry with --ignore-stdin option.

Additional information, screenshots, or code examples

I've found the final answer in #1017 and when using --debug option.
HTTPie should be able to detect if stdin contents come from a pipe or are for xargs or a bash loop.
In any case, displaying a warning when a request fails with stdin content could prevent users some headaches.

@landure landure added bug Something isn't working new Needs triage. Comments are welcome! labels Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!
Projects
None yet
Development

No branches or pull requests

1 participant