Skip to content

The proxy serves an ASK's boolean instead of failing to read it as rows - #98

Open
namedgraph wants to merge 1 commit into
masterfrom
ft-proxy-ask-boolean
Open

namedgraph wants to merge 1 commit into
masterfrom
ft-proxy-ask-boolean

Conversation

@namedgraph

Copy link
Copy Markdown
Member

The Linked Data proxy picks how to read an upstream answer by its content type alone, and every SPARQL results type went to readEntity(ResultSetRewindable.class). An ASK answers with a boolean in those same types, and Jena 6.1 refuses to read one as a result set:

ResultSetException: Not a ResultSet result

So any proxied ASK failed. That has always applied to remote endpoints, and since Core 5.0.6 it applies to Core endpoints too, now that they answer ASK with a real boolean (AtomGraph/Core#40).

What changes

  • ProxyRequestFilter: the results branch reads Jena's SPARQLResult and hands it to a new getResponse(SPARQLResult, StatusType). A result set goes on to the existing getResponse(ResultSetRewindable, …), and a boolean goes to a new getBooleanResponse.
  • getBooleanResponse offers only the result set media types a boolean can be written in, filtered by SPARQLResultProvider.isBooleanWriteable. Jena has no boolean encoding in Thrift or Protobuf, and (X)HTML has no writer for one, so those negotiate to 406. The entity tag comes from ResultSetUtils.hashBoolean.
  • Application: registers Core's SPARQLResultProvider on the server and on the client. The client registration is what lets the proxy read a SPARQLResult.

Tests

ProxyRequestFilterTest gains four cases:

  • a boolean is served as a boolean
  • true and false carry different entity tags
  • Protobuf and HTML are refused with 406
  • a result set is unchanged

mvn clean install: all 20 tests pass.

LinkedDataHub has its own copy of this filter and gets the same fix separately, with an HTTP test that runs CONSTRUCT, SELECT and ASK through the proxy.

🤖 Generated with Claude Code

The proxy decides what an upstream answered by its content type alone, and every SPARQL results type went to readEntity(ResultSetRewindable). An ASK answers with a boolean in the same types, and Jena refuses to read a boolean document as a result set:

    ResultSetException: Not a ResultSet result

So a proxied ASK failed, against any remote endpoint and, since Core 5.0.6, against a Core endpoint too.

The results branch now reads Jena's SPARQLResult, the union over what a query returns, through Core's SPARQLResultProvider, which is registered here on the server and on the client. getResponse(SPARQLResult, StatusType) dispatches: a result set takes the existing response, a boolean a new getBooleanResponse, which offers only the result set media types a boolean can be written in - Jena has no boolean encoding in Thrift or Protobuf, and (X)HTML has no writer for one - with an entity tag from ResultSetUtils.hashBoolean.

Tests cover a boolean served as one, true and false tagged apart, Protobuf and HTML refused, and a result set unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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