apache / apache/jena

Incorrect substitution of a variable for a blank node in a service pattern

Open
#2,994 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
1.4k
Forks
712
Avg merge
15h 41m
Merged PRs (30d)
53

Description

### Version

5.3.0

### What happened?

During my experiments, I observed that Jena incorrectly evaluates the following federated query, which uses a blank node:

```sparql
PREFIX sd:

SELECT * WHERE {
BIND(bnode() as ?BN)

SERVICE {
?S sd:endpoint ?BN.
}
}
```

This query should not return any solutions because blank nodes are only locally scoped within RDF stores. However, it returns the following result:

| ?BN | ?S |
|-|-|
| _:b0 | <https://idsm.elixir-czech.cz/sparql/endpoint/idsm> |

The problem arises because Jena inappropriately substitutes `?BN` with `_:b0` when it evaluates the service pattern:

```sparql
SELECT *
WHERE
{ ?S _:b0 }
```

### Relevant output and stacktrace

```shell

```

### Are you interested in making a pull request?

None

Contributor guide

Open the contributing guide

Research direction

No source file or test is identified in the report. Start by reproducing the federated SPARQL query on Jena 5.3.0 and trace service-pattern evaluation where the blank node is substituted; done means the query returns no solutions because the blank node remains locally scoped.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.