nichtich / wdq

Command line interface to Wikidata Query Service
https://metacpan.org/pod/distribution/App-wdq/script/wdq
Other
54 stars 4 forks source link

Catch and report API timeout #34

Open merkys opened 2 years ago

merkys commented 2 years ago

For some queries the server timeouts, but wdq dies with rather obscure message about failure to parse JSON. Failcase:

SELECT ?item ?smiles ?itemLabel
     WHERE { ?item wdt:P31 wd:Q11173 .
             ?item wdt:P233 ?smiles .
             SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }

It would be great if wdq could check for the HTTP return status (I believe server-side timeouts should set a proper one) and report it back to the user.

nichtich commented 2 years ago

Thanks for reporting. Could you please try wikibase-cli instead?

merkys commented 2 years ago

Thanks for suggestion. Although I prefer wdq due to its lightweight dependencies (all are system-provided by Debian/Ubuntu OSes).

versant2612 commented 1 year ago

Hello, I received this error and I think it is due to timeout invalid character encountered while parsing JSON string, at character offset 1355571275 (before "\nPREFIX prov: <http...") at /usr/local/share/perl/5.30.0/RDF/Trine/Iterator/JSONHandler.pm line 68. Can you confirm?

merkys commented 1 year ago

@versant2612 this indeed seems very similar to what I am getting:

invalid character encountered while parsing JSON string, at character offset 172474431 (before "\nPREFIX wd: <http:/...") at /usr/share/perl5/JSON.pm line 190.

Do you get your error by using wdq or something else?

versant2612 commented 1 year ago

@merkys using wdq.

versant2612 commented 1 year ago

And I have another case that I didn't receive any error using wdq (it seems that there were no results because the header was printed) but the query timeout when execute in WDQS

PREFIX prov: http://www.w3.org/ns/prov# PREFIX wikibase: http://wikiba.se/ontology#

SELECT ?referrer (count( ?ref) as ?ref_per_ref) WHERE { ?ref ?referrer ?pr_obj . VALUES ?referrer {pr:P854} } GROUP BY ?referrer

merkys commented 1 year ago

This seems easy to fix, if the wish is to get a proper error message only, which would be sufficient to me. @nichtich would you accept a PR if I create one?