maxlath / wikibase-cli

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

wd sparql -f csv triggers JSON SyntaxError #185

Closed tmtmtmtm closed 8 months ago

tmtmtmtm commented 8 months ago

Since updating to v18, wd sparql -f csv is warning about JSON SyntaxErrors.

For example, given a sparql.js of:

module.exports = (item) => {
  return `SELECT ?page WHERE { wd:${item} ^schema:about ?page }`
}

then wd sparql -f csv sparql.js gives:

could not parse response body as JSON SyntaxError: Unexpected token 'p', "page
http"... is not valid JSON
    at JSON.parse (<anonymous>)
    at handleResponse (file:///opt/homebrew/lib/node_modules/wikibase-cli/lib/request.js:48:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { body: 'page\r\nhttps://id.wikipedia.org/wiki/Gubernur_Aceh\r\n' }
page
https://id.wikipedia.org/wiki/Gubernur_Aceh

(FWIW: The Unexpected token 'p' seems to vary based on the first column name: if this was 'SELECT ?item, ?page' then it gets: Unexpected token 'i', "item,page)

maxlath commented 8 months ago

Thank for reporting. A test was missing so I didn't see that regretion. Patched 7438a84 published in v18.0.1