Skip to content

Conversation

@dpb587
Copy link

@dpb587 dpb587 commented Jan 22, 2026

I'm not sure if this repository is still maintained or worth changing at this point, but I ran into #16 and took a detour to see if there was a quick fix. This is a partial fix with the remaining issues presumably related to the upstream rdflib.js package which I did not research further. Personally, I have moved to integrating the test files directly into my automated tests (thank you for the curated test cases), so the browser-based testing page is no longer directly relevant to me. Regardless, I thought it might be helpful to document the findings and this potential fix for others.

These were the errors I ran into, however, I'm not sure how this would have been working previously, so there's a possibility I have misunderstood something else entirely. The patch tries to work around them with a minimal set of changes.

  • the kb.query callback function receives an array of bindings for a match, not true or false. As an ASK query, there are no bindings, so the callback is called with an empty [] array which never equates to the expectedResults boolean.
  • the kb.query function is asynchronous, so a case is always marked as an error. Then the callback may or may not be invoked, but is effectively a no-op since it only reassigns the scoped queryResult.
  • the $rdf.SPARQLToQuery parser throws an error on several cases for a variety of reasons which always interrupts the "Run All Tests" feature.

Since the SPARQL parsing fails, I changed the "Run All Tests" behavior to continue after an error. That might not be a desirable default, but seemed more confusing to classify it as FAIL or introduce error-specific handling. The related console messages for the parse errors are:

Error fetching /test-suite/test-cases/rdfa1.1/xml/0099.sparql: Error: Predicate But is not a predicate type
Error fetching /test-suite/test-cases/rdfa1.1/xml/0290.sparql: Error: NamedNode IRI "#" must be absolute.
Error fetching /test-suite/test-cases/rdfa1.1/xml/0297.sparql: Error: NamedNode IRI "[" must be absolute.
Error fetching /test-suite/test-cases/rdfa1.1/xml/0298.sparql: Error: NamedNode IRI "[" must be absolute.
Error fetching /test-suite/test-cases/rdfa1.1/xml/0318.sparql: Error: Subject is not a subject type

The kb.query function includes a fourth argument, onDone, which, by name, is called after the query has been fully evaluated. This is mostly true, but occasionally and predictably it is not. As a workaround, I used a timeout fallback for updating the test result and allow the running to tests to continue. The related console messages for the timeout errors are:

test-model.js:167 test 0259 timeout waiting for query to call done callback
test-model.js:167 test 0295 timeout waiting for query to call done callback
test-model.js:167 test 0301 timeout waiting for query to call done callback
test-model.js:167 test 0330 timeout waiting for query to call done callback
test-model.js:167 test 0331 timeout waiting for query to call done callback
test-model.js:167 test 0332 timeout waiting for query to call done callback

I did try updating to the latest rdflib.js (v2.3.5) and switching to the querySync function. The same SPARQL query parse errors still exist, and instead of relying on the onDone callback (which is apparently now documented with "do not use"), it errors with a caught message of Sync query should have called done function.

curl -Lo javascripts/rdflib.js 'https://cdn.jsdelivr.net/npm/rdflib@2.3.5/dist/rdflib.min.js'

Since it did not seem to fix anything (nor break anything), I did not include it in this change.

There are still some parse errors from rdflib.js for SPARQL queries.
Includes a workaround for missing callback from query evals.

Related: rdfa#16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant