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

Get request blows up if params is nil #422

Closed
thiagomajesk opened this issue Oct 16, 2024 · 3 comments · May be fixed by #423
Closed

Get request blows up if params is nil #422

thiagomajesk opened this issue Oct 16, 2024 · 3 comments · May be fixed by #423

Comments

@thiagomajesk
Copy link

Hi! Thanks for this great lib!

Exactly what the title says, the code below will blow up when params is nil:

 Req.get(Req.new([url: "/", params: opts[:query]]))

I think we should probably coalesce it into an empty map or something.

 ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, Jason.OrderedObject, List, Map, MapSet, Range, Req.Response.Async, Stream
stacktrace:
(elixir 1.17.2) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.17.2) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.17.2) lib/enum.ex:4423: Enum.map_intersperse/3
(elixir 1.17.2) lib/enum.ex:1804: Enum.map_join/3
(req 0.5.6) lib/req/steps.ex:524: Req.Steps.put_params/2
(req 0.5.6) lib/req/request.ex:1087: Req.Request.run_request/1
(req 0.5.6) lib/req/request.ex:1047: Req.Request.run/1
@wojtekmach
Copy link
Owner

Agreed, we should allow nil value. PR appreciated!

@thiagomajesk
Copy link
Author

Hi @wojtekmach, done: #423 💪

@wojtekmach
Copy link
Owner

Closing in favour of PR, thanks!

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 a pull request may close this issue.

2 participants