Skip to content

Remote transaction sends base URI with < and > delimiters, causing invalid IRIs to be created on remote end #5403

@avataar

Description

@avataar

Current Behavior

When using a remote transaction in RDF4J and adding RDF data (e.g., Turtle) that requires a base URI, the base URI is serialized with angle brackets around it — for example:

<http://example.com/>

instead of the expected:

http://example.com/

On the remote end, the base URI is expected without < and >. This mismatch leads to invalid IRIs being constructed. If the data contains:

<foo> a <bar> .

The remote endpoint interprets <http://example.com/> literally, leading to corrupted IRIs:

<%3Chttp://example.com/foo> a <%3Chttp://example.com/bar> .

Expected Behavior

The base URI should be sent without < and > delimiters so the remote endpoint interprets it correctly and the created IRIs look like http://example.com/foo.

NOTE: I'm not sure what the protocol agreement is in this case but it should be the same on both client and server. Either both should use < and > or both should not use it.

Steps To Reproduce

  1. Use RDF4J to open a remote transaction.
  2. Add Turtle data with relative IRIs and provide the base URI externally.
  3. Observe the serialized request payload — the base URI includes < and > delimiters.
  4. On the remote server, inspect the created IRIs — they have %3C prepended (< but URL-encoded).

Code:

var repository = new HTTPRepository("http://localhost:8080/repositories/test");
try (var conn = repository.getConnection()) {
    conn.begin();
    conn.add(new StringReader( "<foo> a <bar> ."),
            "http://example.com/",
            RDFFormat.TURTLE);
    conn.commit();
    try (var statements = conn.getStatements(null, null, null, false)) {
        Rio.write(statements, System.out, RDFFormat.TURTLE);
    }
}

Version

5.1.4

Are you interested in contributing a solution yourself?

None

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions