[Bug][Admin GraphQL] customerUpdate fails with "Customer tags is invalid"

[Bug][Admin GraphQL] customerUpdate fails with "Customer tags is invalid"

adriele
New Member
4 0 0

This issue is very similar to this one [Bug][Admin GraphQL] updateOrder fails with "Order tags is invalid"  

First of all, Shopify's docs are a bit confusing. It marks tags as [String!], docs here

Screen Shot 2022-01-18 at 17.41.27.png

 

Input scheme also marks tags as an array of strings:

Screen Shot 2022-01-18 at 17.41.51.png

This is what GraphQL docs says about brackets and ! symbol:

We can use a type modifier to mark a type as a List, which indicates that this field will return an array of that type. In the schema language, this is denoted by wrapping the type in square brackets, [ and ]. It works the same for arguments, where the validation step will expect an array for that value.

The Non-Null and List modifiers can be combined. For example, you can have a List of Non-Null Strings:

 

 

myField: [String!]

 

 

 

But if you at the variables, tags looks like a plain string:
Screen Shot 2022-01-18 at 17.42.17.png
Maybe it should be?

 

 

tags: []​ # empty array

 

 

instead of 

 

 

tags: "" # plain string

 

 

 I wonder.

 

There's also this example on how to update customer's tags. Tags are an array with a single plain string comma-separated

 

 

tags: ["Test tag, New tag"]

 

 

instead of an array of strings

 

 

tags: ["Test tag", "New tag"]

 

 

 

Screen Shot 2022-01-18 at 17.43.40.png

 

I'm using the official ruby gem. I generated a scheme from 2021-10 version and I also found another description of what tags could be (though this is related to SubscriptionDraft):

Screen Shot 2022-01-18 at 17.51.09.png

 

I wonder what Shopify understands by "a comma-separated list". By definition, it should be 

 

 

tags: ["Test tag", "New tag"] # array of strings

 

 

But in the docs, tags could be something else.

And finally, here's the error I'm getting when trying to update customer's tags by using those 2 tags formats:

 

 

tags: ["Test tag", "New tag"] # array of strings

 

 

tags: "Test tag, New tag" # plain string, something like array.join(", ")

 

 

Screen Shot 2022-01-18 at 17.45.07.png

The query was performed with these variables: 

{:input=>{:id=>"gid://shopify/Customer/customer_id", :tags=>"Smile VIP - Gold"}}

I don't know what make a tag invalid, what's wrong with the tags, or if I should try the third option - pass the tags as a 

 

tags: ["Tag 1, tag 2"] # array of string with single element

 

 

When I was passing tags as an array of strings, 100% of the mutation failed. Passing as a plain string, a few mutations work and a few, fail.

 

I'd like to add that, via Postman, I was able to update the customer's tag using either of the 3 formats. But in production environment, Shopify's GraphQL API will just throw this invalid tag error.

 

Appreciate if somebody could clarify why this error is happening and how tags should be passed.

Reply 1 (1)

adriele
New Member
4 0 0

A few updates on this:
- We don't have a request ID since we're using the shopify_api gem and I couldn't find how to get this ID from the response body
Randomly, tags are refused by Shopify. When it happens, it’s only refused the first time, upon repeating the request a second time, it works. 

- We were passing tags as an array before, mutations failed with “{”field”:[“tags”],“message”:“Customer tags is invalid”}” error, and we updated to pass tags as a comma separated string and we still received the same error, randomly.