From 13e81bf536330af216dfdade9e3356bb7c4f3f5f Mon Sep 17 00:00:00 2001 From: Cameron Sajedi Date: Fri, 25 Jul 2025 09:13:25 -0400 Subject: [PATCH] fix: return W3C standard JSON format for SPARQL ASK queries ASK queries were returning raw JavaScript booleans (true/false) instead of the W3C SPARQL 1.1 standard JSON format {"head": {}, "boolean": true/false}. This fix uses QueryResultsSerializer to properly format ASK query results, ensuring compatibility with standards-compliant SPARQL applications and consistency with SELECT/CONSTRUCT query behavior. The issue was in ng-verifier/src/request_processor.rs where AppResponseV0::True/False were returned instead of a properly serialized QueryResult. Fixes: Non-standard ASK query responses Reference: https://www.w3.org/TR/sparql11-results-json/ --- ng-verifier/src/request_processor.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ng-verifier/src/request_processor.rs b/ng-verifier/src/request_processor.rs index 8d92a07..1d2e797 100644 --- a/ng-verifier/src/request_processor.rs +++ b/ng-verifier/src/request_processor.rs @@ -294,11 +294,13 @@ impl Verifier { )) } QueryResults::Boolean(b) => { - if b { - AppResponse::V0(AppResponseV0::True) - } else { - AppResponse::V0(AppResponseV0::False) - } + // FIX: Serialize boolean results as standard SPARQL JSON format + // instead of returning AppResponseV0::True/False + let serializer = QueryResultsSerializer::from_format(QueryResultsFormat::Json); + let result = serializer + .serialize_boolean_to_write(Vec::new(), b) + .map_err(|_| "QueryResult serializer error")?; + AppResponse::V0(AppResponseV0::QueryResult(result)) } QueryResults::Graph(quads) => { let mut results = vec![];