maxlath / wikibase-cli

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

wd data --props labels --simplify presupposes there is a label #112

Closed rwst closed 4 years ago

rwst commented 4 years ago
ralf@ark:~/wikidata> echo 'Q57971954' |wd data --props labels.en --simplify
TypeError: Cannot read property 'value' of null
    at /usr/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/helpers/simplify_text_attributes.js:7:54
    at Array.reduce (<anonymous>)
    at Object.data (/usr/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/helpers/simplify_text_attributes.js:2:28)
    at simplifyIfDefined (/usr/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/helpers/simplify_entity.js:39:48)
    at Object.simplifyEntity [as entity] (/usr/lib/node_modules/wikibase-cli/node_modules/wikibase-sdk/lib/helpers/simplify_entity.js:14:5)
    at entities.map.entity (/usr/lib/node_modules/wikibase-cli/lib/fetch_and_log_ids_data.js:22:50)
    at Array.map (<anonymous>)
    at onResponse (/usr/lib/node_modules/wikibase-cli/lib/fetch_and_log_ids_data.js:22:27)
    at getNextBatch (/usr/lib/node_modules/wikibase-cli/lib/get_entities_by_batches.js:28:5)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Context: undefined

Of course if this is the only label requested then it can be handled. But I encountered the error with a batch of 1.8k items that I requested. I would expect to just get an empty label instead of an error. And indeed:

ralf@ark:~/wikidata> echo 'Q57971954' |wd data --props labels.en
{"type":"item","id":"Q57971954","labels":{"en":null}}
maxlath commented 4 years ago

fix by https://github.com/maxlath/wikibase-sdk/commit/8eed695 and published in v12.0.3

rwst commented 4 years ago

Thanks!