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

Error while passing tax_ids to catalog_item #5

Open
etiennelacoursiere opened this issue Feb 4, 2021 · 2 comments
Open

Error while passing tax_ids to catalog_item #5

etiennelacoursiere opened this issue Feb 4, 2021 · 2 comments

Comments

@etiennelacoursiere
Copy link

HI,

We've been using your library in our project and so far it's been great!

However this morning i encountered and error while trying to pass :tax_ids to a catalog_item.
Here is the spec for that:

catalog_item() :: %{
  ...
  optional(:tax_ids) => [binary()]
  ...
 }

Here's what i'm doing in my code.

params = %{
  idempotency_key: UUID.uuid1(),
  object: %{
    type: "ITEM",
      id: "#SOME_RANDOM_ID",
      item_data: %{
        name: name,
        category_id: department.payment_processor_data.id,
        tax_ids: ["SOME_ID", "SOME_OTHER_ID"]
      }
  }
}

SquareUp.V2.CatalogObject.upsert(client, %{}, params, %{})

and here's the error i'm getting:

** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in Keyword.merge/2
        (elixir 1.10.4) Keyword.merge([kind: nil, distinct: false, min_count: 0, max_count: :infinity, into: nil], #Norm.Spec<is_binary()>)
        (norm 0.12.0) lib/norm.ex:281: Norm.coll_of/2
        (norm 0.12.0) lib/norm/core/spec.ex:135: Norm.Conformer.Conformable.Norm.Core.Spec.conform/3
        (norm 0.12.0) lib/norm/core/schema.ex:96: Norm.Conformer.Conformable.Norm.Core.Schema.check_spec/3
        (elixir 1.10.4) lib/enum.ex:1400: anonymous fn/3 in Enum.map/2
        (stdlib 3.12.1) maps.erl:232: :maps.fold_1/3
        (elixir 1.10.4) lib/enum.ex:2127: Enum.map/2
        (norm 0.12.0) lib/norm/core/schema.ex:74: Norm.Conformer.Conformable.Norm.Core.Schema.check_specs/3
        (norm 0.12.0) lib/norm/core/selection.ex:81: Norm.Conformer.Conformable.Norm.Core.Selection.conform/3
        (norm 0.12.0) lib/norm/core/schema.ex:96: Norm.Conformer.Conformable.Norm.Core.Schema.check_spec/3
        (elixir 1.10.4) lib/enum.ex:1400: anonymous fn/3 in Enum.map/2
        (stdlib 3.12.1) maps.erl:232: :maps.fold_1/3
        (elixir 1.10.4) lib/enum.ex:2127: Enum.map/2
        (norm 0.12.0) lib/norm/core/schema.ex:74: Norm.Conformer.Conformable.Norm.Core.Schema.check_specs/3
        (norm 0.12.0) lib/norm/core/selection.ex:81: Norm.Conformer.Conformable.Norm.Core.Selection.conform/3
        (norm 0.12.0) lib/norm/core/schema.ex:96: Norm.Conformer.Conformable.Norm.Core.Schema.check_spec/3
        (elixir 1.10.4) lib/enum.ex:1400: anonymous fn/3 in Enum.map/2
        (stdlib 3.12.1) maps.erl:232: :maps.fold_1/3
        (elixir 1.10.4) lib/enum.ex:2127: Enum.map/2
        (norm 0.12.0) lib/norm/core/schema.ex:74: Norm.Conformer.Conformable.Norm.Core.Schema.check_specs/3

It's seems to be related to nested data structure in Norm more than your lib if i understand correctly but I thought i'll post this here if you already encountered this errror or if you have any idea what's going on.

@nkezhaya
Copy link
Owner

Hi @etiennelacoursiere ! Sorry for the late reply. I was on vacation and was a bit overwhelmed by the to do list after getting back.

Are you still running into this? Did you get anywhere closer to figuring out the issue?

@etiennelacoursiere
Copy link
Author

Unfortunately we did not figured out yet. We had to move quickly so for the moment we forked the library and did a really sketchy bypass of Norm in the function we needed as i couldn't figured what was the problem.

For example in CatalaogObject.upsert/4 i did this.

params_spec = schema(%{})
# params_spec = Norm.Delegate.delegate(&SquareUp.NormSchema.batch_delete_catalog_objects_request/0)

The problem occur when i tried to pass a list of binary. For example It happens also in CatalogObjects.batch_delete/4 when i pass a list of ids ( string ) to delete.

CatalogObjects.batch_delete(client, %{}, %{object_ids: ids}, %{})

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

2 participants