beam-community / avro_ex

An Avro Library that emphasizes testability and ease of use.
https://hexdocs.pm/avro_ex/AvroEx.html
67 stars 27 forks source link

Records without a name fail poorly #60

Closed davydog187 closed 2 years ago

davydog187 commented 2 years ago

If you have a record without a name field, you'll get an error like

** (FunctionClauseError) no function clause matching in Ecto.Changeset.add_error/4

    The following arguments were given to Ecto.Changeset.add_error/4:

        # 1
        #Ecto.Changeset<action: nil, changes: %{name: "match", type: %{"fields" => [%{"name" => "uuid", "type" => "string"}, %{"name" => "type", "type" => "string"}, %{"name" => "league", "type" => "string"}], "type" => "record"}}, errors: [], data: #AvroEx.Schema.Record.Field<>, valid?: true>

        # 2
        :type

        # 3
        %{name: ["can't be blank"]}

        # 4
        []

    Attempted function clauses (showing 1 out of 1):

        def add_error(%Ecto.Changeset{errors: errors} = changeset, key, message, keys) when is_binary(message)

    (ecto 3.7.1) lib/ecto/changeset.ex:1665: Ecto.Changeset.add_error/4
    (ecto 3.7.1) lib/ecto/changeset.ex:851: anonymous fn/4 in Ecto.Changeset.on_cast_default/2
    (ecto 3.7.1) lib/ecto/changeset/relation.ex:137: Ecto.Changeset.Relation.do_cast/6
    (ecto 3.7.1) lib/ecto/changeset/relation.ex:351: Ecto.Changeset.Relation.map_changes/9
    (ecto 3.7.1) lib/ecto/changeset/relation.ex:121: Ecto.Changeset.Relation.cast/5
    (ecto 3.7.1) lib/ecto/changeset.ex:822: Ecto.Changeset.cast_relation/4
    (avro_ex 1.2.0) lib/avro_ex/schema.ex:283: AvroEx.Schema.cast_schema/3
    (avro_ex 1.2.0) lib/avro_ex/schema.ex:39: AvroEx.Schema.parse/2