watson-developer-cloud / node-red-node-watson

A collection of nodes for the IBM Watson services
Apache License 2.0
82 stars 86 forks source link

Natural Language Understanding Node now produces version error #392

Closed keyn0te closed 6 years ago

keyn0te commented 6 years ago

Lab setups that used to work before are now giving the following error: "Error: Argument error: version was not specified" I even got this after importing the sample basic examples flow and using my IBM cloud credentials.

hseipp commented 6 years ago

Same error here, running Node-RED on IBM Bluemix (Sydney, Germany regions): nlu-node-error

Note that this did not occur when I only originally only had the "Natural Language Understanding" service bound to my Bluemix app, but as soon as I bound "Natural Language Classifier" (NLC) additionally, this error came up and now stays even when I unbind NLC again.

Trying to work-around by not binding the service(s) but directly specifying the credentials and https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2017-02-27 as endpoint does not work either, I'm getting the same error.

Note that I can reach the service using a Python script from my local machine so this is not related to the service, but must be an issue with the Node-RED node.

hseipp commented 6 years ago

Now tried it with a local Node-RED installation, same error. Note that on that same machine, the watson-developer-cloud node SDK sample provided at https://github.com/watson-developer-cloud/node-sdk#natural-language-understanding is working fine.

hseipp commented 6 years ago

The following patch seems to fix the bug - the node indeed seems to miss setting the version parameter for the underlying watson-developer-cloud node SDK method:

--- node-red-node-watson/services/natural_language_understanding/v1.js.orig 2018-03-23 17:17:24.765574799 +0100
+++ node-red-node-watson/services/natural_language_understanding/v1.js  2018-03-23 17:23:03.997656953 +0100
@@ -184,6 +184,7 @@
         username: username,
         password: password,
         version_date: NaturalLanguageUnderstandingV1.VERSION_DATE_2017_02_27,
+        version: '2017-02-27',
         headers: {
           'User-Agent': pkg.name + '-' + pkg.version
         }
chughts commented 6 years ago

I suspect that this is due to an underlying change to the watson-developer-cloud node.js SDK. My test systems are built with 3.0.6, and both are behaving normally. I will need to bump to the lates version of the SDK in my test systems to first recreate the problem then fix it.

chughts commented 6 years ago

Bumping to 3.2.1 of watson-developer-cloud reproduces the problem

chughts commented 6 years ago

Fixed in V 0.6.7 of the nodes. As this involves a bump in a dependency this will require a regression test of the nodes before release.

hseipp commented 6 years ago

Thank you for taking care of the fix.

The following watson-developer-cloud commit (for 3.1.0) triggered the issue - version_date was replaced by version: https://github.com/watson-developer-cloud/node-sdk/commit/e05e8ee1bd4e0bc8d69a340585579d345e8e9871#diff-16290dbff3ff1d493e0abdda6628eef6 Instead of replacing, some backward compatible change there like for VR would have been a smart move: https://github.com/watson-developer-cloud/node-sdk/commit/e05e8ee1bd4e0bc8d69a340585579d345e8e9871#diff-431a097ca3f6222ade17c653707b76eb

chughts commented 6 years ago

They do have backward compatibility for version_date, but they removed the constants for the version dates, that the node was using.

chughts commented 6 years ago

0.6.7 has been released.