-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
While trying to work with FunWithFlagsUI
(especially with any new flag) from time to time we get such weird error:
ArgumentError :erlang.binary_to_existing_atom/2
errors were found at the given arguments: * 1st argument: not an already existing atom
lib/fun_with_flags/ui/router.ex in anonymous fn/3 in FunWithFlags.UI.Router.do_match/4 at line 99
lib/plug/router.ex in anonymous fn/4 in FunWithFlags.UI.Router.dispatch/2 at line 246
/opt/app/deps/telemetry/src/telemetry.erl in :telemetry.span/3 at line 321
lib/plug/router.ex in FunWithFlags.UI.Router.dispatch/2 at line 242
lib/fun_with_flags/ui/router.ex in FunWithFlags.UI.Router.plug_builder_call/2 at line 1
lib/phoenix/router/route.ex in Phoenix.Router.Route.call/2 at line 42
lib/phoenix/router.ex in Phoenix.Router.__call__/5 at line 425
I think it comes from there:
https://github.com/tompave/fun_with_flags_ui/blob/master/lib/fun_with_flags/ui/router.ex
defmodule FunWithFlags.UI.Router do
...
get "/flags/:name" do
case Utils.get_flag(name) do
...
end
end
...
end
https://github.com/tompave/fun_with_flags_ui/blob/master/lib/fun_with_flags/ui/utils.ex
defmodule FunWithFlags.UI.Utils do
...
def get_flag(name) do
..
case FunWithFlags.SimpleStore.lookup(String.to_existing_atom(name)) do
...
end
...
end
...
end
Maybe it's worth to replace String.to_existing_atom
with String.to_atom
to avoid the issue, what do you think?
Metadata
Metadata
Assignees
Labels
No labels