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

ChangesetParser.extract_messages breaks with tuple types #6

Open
d-webs opened this issue May 29, 2019 · 0 comments
Open

ChangesetParser.extract_messages breaks with tuple types #6

d-webs opened this issue May 29, 2019 · 0 comments

Comments

@d-webs
Copy link

d-webs commented May 29, 2019

I am getting the below error from AbsintheErrorPayload

Request: POST /v2/graphql
** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol String.Chars not implemented for {:array, :map}. This protocol is implemented for: Postgrex.Copy, Postgrex.Query, Decimal, Float, DateTime, Time, List, Version.Requirement, Atom, Integer, Version, Date, BitString, NaiveDateTime, URI
        (elixir) /home/build/elixir/lib/elixir/lib/string/chars.ex:3: String.Chars.impl_for!/1
        (elixir) /home/build/elixir/lib/elixir/lib/string/chars.ex:22: String.Chars.to_string/1
        (absinthe_error_payload) lib/absinthe_error_payload/changeset_parser.ex:114: anonymous fn/2 in AbsintheErrorPayload.ChangesetParser.interpolate_message/1
        (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
        (absinthe_error_payload) lib/absinthe_error_payload/changeset_parser.ex:93: AbsintheErrorPayload.ChangesetParser.construct_message/2
        (ecto) lib/ecto/changeset.ex:2717: anonymous fn/4 in Ecto.Changeset.merge_error_keys/3
        (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
        (ecto) lib/ecto/changeset.ex:2704: Ecto.Changeset.traverse_errors/2
        (ecto) lib/ecto/changeset.ex:2731: anonymous fn/3 in Ecto.Changeset.merge_related_keys/4
        (elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
        (ecto) lib/ecto/changeset.ex:2730: anonymous fn/4 in Ecto.Changeset.merge_related_keys/4
        (stdlib) maps.erl:257: :maps.fold_1/3
        (ecto) lib/ecto/changeset.ex:2731: anonymous fn/3 in Ecto.Changeset.merge_related_keys/4
        (elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
        (ecto) lib/ecto/changeset.ex:2730: anonymous fn/4 in Ecto.Changeset.merge_related_keys/4
        (stdlib) maps.erl:257: :maps.fold_1/3
        (absinthe_error_payload) lib/absinthe_error_payload/changeset_parser.ex:17: AbsintheErrorPayload.ChangesetParser.extract_messages/1

This looks like it is happening because I have a nested type in my model, like this:

schema "products" do
    # ...
    field(:tags, {:array, :string})
    # ...
    timestamps(type: :utc_datetime_usec)
  end

The {:array, :string} type is breaking the interpolate_messages function, as you cannot automatically cast a tuple to a string

@d-webs d-webs changed the title ChangesetParser.extract_messages breaks with ChangesetParser.extract_messages breaks with tuple types May 29, 2019
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

No branches or pull requests

1 participant