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

Product-sync TypeError on attribute null values #215

Open
butenkor opened this issue Feb 24, 2017 · 4 comments
Open

Product-sync TypeError on attribute null values #215

butenkor opened this issue Feb 24, 2017 · 4 comments

Comments

@butenkor
Copy link
Member

Expected behavior

Should not throw an error if product attribute value for set of enums is null:

{
  "name": "laender",
  "value": [
    null
  ]
}

Actual behavior

{"name":"xxx","widget_type":"product-import","hostname":"xxx","pid":1,"level":50,"myMsg":"Error - Error on product sync. Skip and continue.","error":{"type":"TypeError","message":"Cannot set property 'MATCH_CRITERIA' of undefined","name":"TypeError","stack":"TypeError: Cannot set property 'MATCH_CRITERIA' of undefined\n at /app/node_modules/sphere-node-sdk/lib/sync/utils/product.js:79:42\n at Function..each..forEach (/app/node_modules/underscore/underscore.js:153:9)\n at /app/node_modules/sphere-node-sdk/lib/sync/utils/product.js:77:22\n at Function..each..forEach (/app/node_modules/underscore/underscore.js:153:9)\n at patchSetLText (/app/node_modules/sphere-node-sdk/lib/sync/utils/product.js:75:18)\n at /app/node_modules/sphere-node-sdk/lib/sync/utils/product.js:103:9\n at Function..each..forEach (/app/node_modules/underscore/underscore.js:153:9)\n at patch (/app/node_modules/sphere-node-sdk/lib/sync/utils/product.js:97:16)\n at ProductUtils.diff (/app/node_modules/sphere-node-sdk/lib/sync/utils/product.js:112:5)\n at ProductSync.BaseSync.buildActions (/app/node_modules/sphere-node-sdk/lib/sync/base-sync.js:26:24)\n at ProductSync.buildActions (/app/node_modules/sphere-node-sdk/lib/sync/product-sync.js:25:47)\n at /app/node_modules/sphere-product-import/dist/product-import.js:352:37\n at tryCatcher (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/util.js:26:23)\n at Promise._settlePromiseFromHandler (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/promise.js:507:31)\n at Promise._settlePromiseAt (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/promise.js:581:18)\n at Promise._settlePromises (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/promise.js:697:14)\n at Async._drainQueue (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/async.js:123:16)\n at Async._drainQueues (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/async.js:133:10)\n at Immediate.Async.drainQueues (/app/node_modules/sphere-product-import/node_modules/bluebird/js/main/async.js:15:14)\n at runCallback (timers.js:649:20)\n at tryOnImmediate (timers.js:622:5)\n at processImmediate [as _immediateCallback] (timers.js:594:5)"},"msg":"","time":"2017-02-19T06:40:35.105Z","v":0}

Steps to reproduce the behavior

@hisabimbola
Copy link
Contributor

Hi @butenkor

According to the documentation here, the attribute value is set to null when you want to remove it from the variant.

So instead of passing null in an array, passing is as the value does not throw an error
e.g

{
  "name": "laender",
  "value": null
}

Or can you provide a valid use case where there is a need to have null in an array.

@butenkor
Copy link
Member Author

We noticed this issue as there was an error in JSON structure of data to import so values were not properly populated. If we want to delete an attribute or unset it than we just do not provide it in new_object so that sync can calculate attribute deletion automatically (it works already). Here it is obvious that value of enum is wrong but this value should go to API and API should response with 400 error. Instead whole import process is endangered as sync module throws TypeError.

@daern91
Copy link
Contributor

daern91 commented Mar 8, 2018

Hi @butenkor, does this still have to be fixed since we are deprecating?

@butenkor
Copy link
Member Author

butenkor commented Mar 8, 2018

It does not have high priority for us as we applied workaround on our side but i see at as a bug as one can continue on 400 API errors but can not on JS TypeError as you never know what is behind it so the whole process gets aborted and requires immediate fix release and rollout (otherwise process would get stuck on same error repeatedly). It would be nice if it could be fixed.

@daern91 daern91 removed their assignment Jul 10, 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

3 participants