maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
223 stars 24 forks source link

v16.0.0: Cannot perform queries on Ubuntu 20.04, node 14. -- v15.17.0 works #161

Closed knbknb closed 2 years ago

knbknb commented 2 years ago

I run wikibase-cli as a Docker container, and have created a wb alias, for a docker run command, with Docker volumes, as mentioned in the documentation.

This version of wikibase-cli works properly

wb -V
15.17.0

wb label Q1
universe

This one v16.0.0. doesn't

docker image ls 

maxlath/wikibase-cli  latest be511939e1fa   3 weeks ago     87.8MB

I can reset the config, and then I can run this, and the v16 command doesn't crash (yet):

wb -V
16.0.0

wb config reset

Still possible:

wb label Q1

A Wikibase instance should be specificed.

This can be done in config, ex:
  $  wb config instance https://www.wikidata.org

or with the -i,--instance command option:
  $  wb label Q1 -i https://www.wikidata.org

wb config instance https://www.wikidata.org # no crash

However:

wb label Q1

Now it crashes:

(node:12) UnhandledPromiseRejectionWarning: ReferenceError: URLSearchParams is not defined
    at stringifyQuery (/usr/local/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/utils/build_url.js:3:66)
    at queryObj (/usr/local/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/utils/build_url.js:15:38)
    at /usr/local/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/queries/get_entities.js:46:10
    at module.exports (/usr/local/lib/node_modules/wikibase-cli/lib/entity_data_parser.js:34:15)
    at module.exports.attribute (/usr/local/lib/node_modules/wikibase-cli/lib/entity_attribute_command.js:19:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/wikibase-cli/bin/wb-label:2:43)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
(node:12) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have no idea where to look, the URLSearchParams is not defined error message is pretty generic.


Current config.json:

{
  "instance": "https://www.wikidata.org",
  "credentials": {
    "https://www.wikidata.org": {
      "oauth": {
        "consumer_key": ".....",
        "consumer_secret": "...",
        "token": "---",
        "token_secret": ".."
      }
    }
  },
  "json": false,
  "sparql-endpoint": "https://query.wikidata.org/sparql",
  "lang": "de"
}

FYI: Annoying npm output

nvm use 14
npm does not support Node.js v14.4.0
You should probably upgrade to a newer version of node as we can't make any promises that npm will work with this version. You can find the latest version at https://nodejs.org/
Now using node v14.4.0 (npm v8.10.0)
maxlath commented 2 years ago

ah yes, the Dockerfile wasn't updated after the NodeJS minimal version was moved to 10 (3f4ad7d): now patched (edcbdd7) and published as v16.0.1

knbknb commented 2 years ago

Thanks for the ultrafast response! v16.0.1 works now:

wb -V
16.0.1

wb label Q1
universe

A simple docker pull (or removal of the tag number in the bash-alias) did the trick. No fiddling required.
Thaaanks!