Skip to content

fix(distribution-probe): accept SPARQL results as JSON or XML#425

Merged
ddeboer merged 1 commit into
mainfrom
fix/sparql-probe-accept-xml-results
Jun 1, 2026
Merged

fix(distribution-probe): accept SPARQL results as JSON or XML#425
ddeboer merged 1 commit into
mainfrom
fix/sparql-probe-accept-xml-results

Conversation

@ddeboer
Copy link
Copy Markdown
Member

@ddeboer ddeboer commented Jun 1, 2026

Problem

When probing a SPARQL endpoint, SparqlProbeResult.isSuccess() required the response Content-Type to start with the single Accept header we send for SELECT/ASK queries (application/sparql-results+json). An endpoint that answers in application/sparql-results+xml – a perfectly valid SPARQL Query Results serialization – was therefore classified as a failure even on an HTTP 200, and its body was never validated.

Downstream (e.g. the Dataset Register), that healthy endpoint surfaced as a spurious content-type violation (“HTTP 200 OK”).

This also matters because publishers are asked to declare SPARQL endpoints via dct:conformsTo, not a media type, so success must not hinge on a declared or negotiated serialization.

Change

  • SELECT/ASK probes now negotiate both serializations: Accept: application/sparql-results+json, application/sparql-results+xml;q=0.9.
  • Success is granted when the endpoint answers with any recognized results serialization (JSON or XML); the body is validated with a lightweight structural check per serialization.
  • SparqlProbeResult now carries acceptedContentTypes (a list). The constructor still accepts a single string and normalizes it, so existing consumers remain source-compatible.

Tests

  • New cases: XML SELECT success, XML SELECT without a results element, XML ASK valid/invalid, non-SPARQL XML, the negotiated Accept header, and single-string constructor normalization.
  • Full @lde/distribution-probe suite passes (37 tests); pipeline and distribution-monitor typecheck cleanly against the widened API.

A SELECT or ASK endpoint that answered in application/sparql-results+xml was wrongly classified as unreachable, because success required the response Content-Type to match the single Accept header we sent (application/sparql-results+json). A healthy endpoint then surfaced as a content-type violation and its body was never validated.

SELECT/ASK probes now negotiate both serializations (Accept: application/sparql-results+json, application/sparql-results+xml;q=0.9) and treat either as success, validating the body with a lightweight structural check per serialization. This also aligns with publishers declaring SPARQL endpoints via dct:conformsTo rather than a media type.
@ddeboer ddeboer merged commit ab47716 into main Jun 1, 2026
2 checks passed
@ddeboer ddeboer deleted the fix/sparql-probe-accept-xml-results branch June 1, 2026 20:37
ddeboer added a commit to netwerk-digitaal-erfgoed/dataset-register that referenced this pull request Jun 2, 2026
Brings in ldelements/lde#425: a SPARQL endpoint that answers a SELECT/ASK query in
application/sparql-results+xml (not just +json) is now treated as reachable, fixing the
spurious "HTTP 200 OK" content-type violation seen when validating SPARQL distributions.
In-range bump (packages/core declares ^0.1.4), so only the lockfile changes.
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