-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[>=2.0.0] ValueError: Data must not be a string. #840
Comments
@AxelVoitier thanks for the report. The reason why it fails on AppVeyor is that when you invoke HTTPie from that script, then HTTPie’s stdin is redirected. And redirected stdin is not compatible with extra request data specified on the CLI. It’s easy to reproduce it with: echo 'file data' > file.txt
echo 'stdin data' | http --form httpbin.org/post foo@file.txt
http: error: ValueError: Data must not be a string. The solution is to include $ echo 'ignored stdin data' | http --ignore-stdin --form httpbin.org/post foo@file.txt The bug here is that HTTPie doesn't fail with the following error as it does when you try to send some non-form-file data with redirected stdin on top of that: $ echo 'stdin data' | http --form httpbin.org/post foo@file.txt data=data
http: error: Request body (from stdin or a file) and request data (key=value) cannot be mixed.
Pass --ignore-stdin to let key/value take priority. |
Hello, I can confirm it works with --ignore-stdin. Thanks :). Cheers, |
Hello,
Since the release of 2.0.0, all my CI builds have been failing on the same error from httpie :-(.
I use httpie to post test results to AppVeyor API:
Now it fails with:
As AppVeyor has a way to block a build execution and log on the machine by ssh, I tried to repeat the command manually. And there, quite strangely, it works...:
More strangely, if I then unblock the build and let the original http command execute, then it fails in the same way...
I first though it would be related to a coincident change in AppVeyor environment. But then retried, blocking the build again but this time downgrading to httpie 1.0.3:
And then unblock the script and let the original command execute, and it worked:
It seems the error "ValueError: Data must not be a string." is comming from requests as this old thread indicate: https://stackoverflow.com/questions/27553082/valueerror-data-must-not-be-a-string
But as you can see in the logs above, when downgrading httpie, requests stays the same.
So I guess the issue comes from a mix between how httpie now invokes requests, and some special conditions in AppVeyor build environment (which make things harder to debug...).
Any though?
Cheers,
Axel
The text was updated successfully, but these errors were encountered: