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

Change INVALID_OBJECT_MESSAGE to omit to_h and to_unsafe_h #4701

Merged

Conversation

matej-tkac
Copy link
Contributor

@matej-tkac matej-tkac commented Nov 14, 2023

Issue:

Reason for change:
This message is exposed publicly [thread].

TL;DR:

When constructing a bad input, e.g.

{
  "input"=>{
    "handle"=>"new-product", 
    "title"=>"New product",
    "status"=>"ACTIVE",
    "vendor"=>"Shop 1",
    "productType"=>"",
    "descriptionHtml"=>"",
    "giftCard"=>false,
    "giftCardTemplateSuffix"=>nil, 
    "options"=>["Color", "Size"], 
    "requiresSellingPlan"=>false,
    "tags"=>[],
    "templateSuffix"=>nil,
    "optionValues"=>[
      {"name"=>"Color", "values"=>["Red"]}, 
      {"name"=>"Size", "values"=>["Small"]}
      ]
    }
}

for productOptionsCreate mutation,

the error response returned is

{
  "errors":[
    {
      "message": "Variable $input of type ProductInput! was provided invalid value for       optionValues.0.values.0
      (Expected \"Red\" to be a key-value object responding to `to_h` or `to_unsafe_h`.), optionValues.1.values.0 
      (Expected \"Small\" to be a key-value object responding to `to_h` or `to_unsafe_h`.)",
      "locations":[{"line":1,"column":10}
  ],
      "extensions":{"value":{"handle":"new-product","title":"New product","status":"ACTIVE","vendor":"Shop 1","productType":"","descriptionHtml":"","giftCard":false,"giftCardTemplateSuffix":null,"options":["Color","Size"],"requiresSellingPlan":false,"tags":[],"templateSuffix":null,"optionValues":[{"name":"Color","values":["Red"]},{"name":"Size","values":["Small"]}]},"problems":[{"path":["optionValues",0,"values",0],"explanation":"Expected \"Red\" to be a key-value object responding to `to_h` or `to_unsafe_h`."},{"path":["optionValues",1,"values",0],"explanation":"Expected \"Small\" to be a key-value object responding to `to_h` or `to_unsafe_h`."}]}}]}

@matej-tkac matej-tkac changed the title Change INVALID_OBJECT_MESSAGE to omit to_h and to_unsafe_h Change INVALID_OBJECT_MESSAGE to omit to_h and to_unsafe_h Nov 14, 2023
@rmosolgo rmosolgo added this to the 2.1.7 milestone Nov 14, 2023
@matej-tkac matej-tkac force-pushed the mtkac/change-invalid-object-message branch from 3705de1 to d3e82cc Compare November 15, 2023 12:26
@rmosolgo
Copy link
Owner

Thanks for this improvement!

@rmosolgo rmosolgo merged commit b8948d5 into rmosolgo:master Nov 21, 2023
12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants