maxlath / wikibase-cli

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

TypeError: Cannot read property 'type' of undefined #46

Closed almereyda closed 4 years ago

almereyda commented 6 years ago

After following an ominuous link in the documentation and recreating a JSON following the example as of q224.json as

{
  "id": "Q224",
  "claims": {
    "P4": "Q6",
    "P8": "Q218"
  }
}

with a valid configuration for a custom Wikibase instance, a stacktrace is thrown:

~/.tmp $ wd edit-item q224.json
TypeError: Cannot read property 'type' of undefined
    at module.exports.propertyId (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/properties/find_datatype.js:24:55)
    at module.exports (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/build_claim.js:9:20)
    at obj.(anonymous function).values.map.value (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/format.js:40:39)
    at Array.map (native)
    at /home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/format.js:40:26
    at Array.reduce (native)
    at Object.claims (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/format.js:22:32)
    at module.exports.data (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/validate_and_format_data.js:31:33)
    at err (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/edit.js:17:22)
    at _validateAndFormatData (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/edit.js:15:10)
    at data (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/node_modules/wikidata-edit/lib/entity/edit.js:7:12)
    at cmd (/home/ya/.nvm/versions/node/v6.9.4/lib/node_modules/wikidata-cli/lib/edit/edit_command.js:38:50)
    at process._tickCallback (internal/process/next_tick.js:103:7)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
maxlath commented 6 years ago

this is an issue with custom instances and wikidata-edit, which isn't addressed from wikidata-cli yet

maxlath commented 6 years ago

there are actually two different problems here:

almereyda commented 6 years ago

We do have such a SPARQL endpoint. What can I do to support mitigating this infrastructural change, as it proposedly affects multiple repositories?

And to illustrate my suprise about properties having a type. Where are these documented and coming from? Why are those not within each Wikibase's namespace (P & Q) ?

I am wondering why these types are hardcoded, because I feel this is working against Linked Data principles here, excluding the schema of the data from its own representation.

On 17 December 2017 at 00:37, Maxime Lathuilière notifications@github.com wrote:

there are actually two different problems here:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maxlath/wikidata-cli/issues/46#issuecomment-352219715, or mute the thread https://github.com/notifications/unsubscribe-auth/ABka_JHYz1zbmzJC8Vh38A86558QZXL-ks5tBFQtgaJpZM4RBZv6 .

maxlath commented 6 years ago

I don't know the internals of Wikibase, but a type is associated to each property, as you can see in this query, which links to this page where those types seem to be defined

maxlath commented 5 years ago

so if you make this same query but specifying the customized SPARQL endpoint, isn't it working?

wd edit-item q224.json --instance http://some/wikibase/instance/w/api.php --sparql-endpoint http://some/sparql/endpoint
almereyda commented 5 years ago

Yes, I managed to mass-add items and translations with the flag after the patch had been provided. Let me find the sources as a proof ...

On Sun, 23 Sep 2018 at 10:08, Maxime Lathuilière notifications@github.com wrote:

so if you make this same query but specifying the customized SPARQL endpoint, isn't it working?

wd edit-item q224.json --instance http://some/wikibase/instance/w/api.php --sparql-endpoint http://some/sparql/endpoint

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maxlath/wikidata-cli/issues/46#issuecomment-423799457, or mute the thread https://github.com/notifications/unsubscribe-auth/ABka_OeBusAYzPX2J502RsD_1vUZDbJeks5ud0FrgaJpZM4RBZv6 .

maxlath commented 4 years ago

since wikibase-edit@v3.0.0, the map of properties datatype is generated by requesting the Wikibase server instead of relying on a possible SPARQL endpoint, making this all class of errors disappear \o/ wikibase-edit will be updated to >v3.0.0 in the very soon coming v8.0.0