Skip to content

solved misleading http status codes at sparql when wrongmissing model and missing query#50

Open
wmehling wants to merge 2 commits into
mainfrom
36-misleading-http-status-codes-at-sparql-when-wrongmissing-model-and-missing-query
Open

solved misleading http status codes at sparql when wrongmissing model and missing query#50
wmehling wants to merge 2 commits into
mainfrom
36-misleading-http-status-codes-at-sparql-when-wrongmissing-model-and-missing-query

Conversation

@wmehling
Copy link
Copy Markdown
Contributor

After update in enilink with HTTP Codes for SPARQL Endpoint, the new functionalit is tested as contract in lf-pod.

Tests should fail, until enilink is released as new snapshot and then resolve.

wmehling and others added 2 commits April 27, 2026 14:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Scala/JUnit contract test suite to pin the SPARQL endpoint’s HTTP status/error-code behavior expected by linkedfactory-pod, aligning lf-pod with recent enilink SPARQL error handling changes.

Changes:

  • Introduces EnilinkSparqlContractTest covering missing model/query/update, unknown model, unsupported Accept, malformed SPARQL, and conflicting parameters.
  • Adds a small in-memory IModelSet setup to support the contract scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +32 to +49
modelSet = factory.createModelSet(MODELS.NAMESPACE_URI.appendFragment("MemoryModelSet"))
Globals.contextModelSet.default.set(Full(modelSet))

val model = modelSet.createModel(sensorModel)
val em = model.getManager
em.add(new Statement(
URIs.createURI("http://example.org/sensors/temp-01"),
URIs.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
URIs.createURI("http://example.org/vocab/Sensor")
))
}

@AfterClass
def tearDown(): Unit = {
if (modelSet != null) {
modelSet.dispose()
modelSet = null
}
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Globals.contextModelSet.default is set in setup(), but tearDown() only disposes modelSet and does not clear/reset the global. Because Full(modelSet) still holds a reference to the disposed model set, later tests can accidentally vend a disposed instance. Please reset/unset Globals.contextModelSet.default in tearDown() (e.g., set it to Empty/remove) before disposing/nulling the modelSet.

Copilot uses AI. Check for mistakes.
Comment on lines +78 to +86
@Test
def missingModelReturns400(): Unit = {
val req = new MockHttpServletRequest(baseUrl) {
method = "GET"
parameters = List("query" -> "SELECT ?s WHERE { ?s ?p ?o }")
headers = Map("Accept" -> List("application/sparql-results+json"))
}
assertErrorContract(execute(req), 400, "MISSING_MODEL:")
}
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description indicates these contract assertions are expected to fail until a newer enilink snapshot is released. Adding a test that is knowingly failing will break CI for this repo unless the enilink dependency version is bumped in the same PR (or the test is temporarily gated, e.g. via @Ignore / an assumption that checks the dependency capability). Please ensure the build remains green on merge by updating the dependency or gating this test until the required enilink version is available.

Copilot uses AI. Check for mistakes.
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.

Misleading HTTP Status Codes at /sparql when wrong/missing ?model and missing ?query

2 participants