Error when trying to write boolean type
See original GitHub issueHi, there,
We recently had this bug report https://github.com/request/request/issues/1693 in request
It turned out that the user passes a boolean
value to one of the form-data’s fields (field:false
) that results in _http_outgoing error in core.
My question is: Is the best place to fix that issue here, like you do for number
types?
// all that streamy business can't handle numbers
if (typeof value == 'number' || typeof value == 'boolean') value = ''+value;
Issue Analytics
- State:
- Created 8 years ago
- Comments:18 (15 by maintainers)
Top Results From Across the Web
java - How to fix "this method must return boolean type" error
The obvious error is that your method does not return anything when count is non-zero. You don't even need a conditional for it...
Read more >[Solved] How do I fix this bool code? - CodeProject
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are...
Read more >ADF throws an error while using boolean variables in ...
Your variables in Master pipeline are declared as Boolean type already. Hence you no need to convert them again to bool using bool()...
Read more >5-1 Boolean expressions
computer programming, one only takes one kind of test: a boolean test — true or ... Your first instinct might be to write...
Read more >C# Booleans - W3Schools
For this, C# has a bool data type, which can take the values true or false . Boolean Values. A boolean type is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The README still says that
boolean
is accepted and MDN still says thatFormData.set()
will convert to string. But this library still explodes, behaving differently than browsers are documented to. Since this is a polyfill to support running browser code outside of the browser, can it be updated to behave like the browser?Thanks.
I think it’s less about crashing in prod and more about it not being the expected result. Also where does JavaScript pass empty strings as false? Surely it’s falsy but Its not like its going to get casted to a Boolean before being sent out as form data.
Also what about consistency? If this is the thought we should just throw for everything that is not a string (excluding buffers and streams) including numbers. I think it would be great for core to have this restriction, but I think it would be best if user facing api’s simply casted to strings automatically. It has to be done at some point, it’s done in the browser, why shouldn’t we do it?
MDN says to cast to a string, but it also has other deprecated things. (But this does seem to be cross browser).
https://developer.mozilla.org/en-US/docs/Web/API/FormData/append#append()_Parameters