Skip to content

Turtle ingest flattens RDF collections into list metadata and drops ( ) statements entirely #1694

Closed

Description

@aaj3f

Long-standing and deliberate in part — this is the list_index storage model, not a regression — but the silent statement loss half of it looks like a plain bug, and the whole thing is now the last unowned item from the W3C burn-down (decision D-13 in docs/audit/burn-down/ROADMAP.md §4b, gates SPARQL10_QUERY_EVAL: basic#list-1..4). Reproduced at 47e96b7b6 through the CLI.

Repro

@prefix ex: <http://example.org/> .
ex:s  ex:items ( ex:a ex:b ex:c ) .
ex:s2 ex:items () .
$ fluree insert d13 --file coll.ttl
Committed t=1, 3 flakes

$ fluree query d13 --sparql 'SELECT ?s ?p ?o WHERE { ?s ?p ?o }'
ex:s ex:items ex:a
ex:s ex:items ex:b
ex:s ex:items ex:c
(3 rows)

$ fluree query d13 --sparql 'SELECT ?l ?x WHERE { ?l rdf:first ?x }'
(0 rows)

As RDF that document denotes eight triples: ex:s ex:items _:l1, three rdf:first/rdf:rest pairs terminating in rdf:nil, and ex:s2 ex:items rdf:nil. We store three, and ex:s2 does not exist in the database at all.

Mechanism

parse_object_list (fluree-graph-turtle/src/parser.rs:820-851) branches on CollectionStyle. Under IndexedItems a ( in object position goes to parse_collection_as_list (:854-866), which emits one emit_list_item per member on the enclosing subject/predicate and never builds a spine; a Nil token (:828-831) advances the lexer and emits nothing — the statement is consumed and discarded without a diagnostic.

CollectionStyle::IndexedItems is the ParserOptions default (fluree-graph-turtle/src/options.rs:27), and every ingest call site takes the default: fluree_graph_turtle::parse (parser.rs:1494) is parse_with_options(..., ParserOptions::default()), and that is what fluree-db-transact/src/import.rs:183, :535 and :910 call. The options file is refreshingly honest about it — the doc comment at options.rs:22-26 already says the shape "is lossy as RDF" and that "the empty collection's rdf:nil triple is dropped entirely."

The conformant reader already exists (ParserOptions::conformant(), options.rs:83) and is exercised by the W3C RDF-syntax suites. It just isn't reachable from any ingest surface.

Why it matters

Two consequences, and I think they deserve to be weighed separately:

  1. () in object position is silent data loss. A statement the user wrote produces zero flakes and no warning. Nothing about the storage model requires that — even under list_index semantics we could store ex:s2 ex:items rdf:nil, or at minimum refuse the statement loudly. This one seems like a bug regardless of how D-13 lands.
  2. Collection structure is unqueryable and doesn't round-trip. ?l rdf:first ?x matches nothing, so any query written against the RDF the document denotes silently returns empty. Turtle → Fluree → Turtle changes the graph's meaning, which is the thing a store is not supposed to do. This half is the D-13 decision.

The decision (D-13)

Three options were on the table in the burn-down roadmap, none adopted:

  • Materialize at ingest — write the rdf:first/rdf:rest spine as real flakes, keeping list_index as an additional edge annotation. Correct and queryable; costs storage and makes the ingest fast paths carry list expansion.
  • Translate at query time — keep storage as-is and synthesize the spine when a query mentions rdf:first/rdf:rest/rdf:nil. Cheap on write, but it's a query-planner special case on a hot path, and it doesn't fix export.
  • Documented divergence — say plainly that Fluree stores RDF collections as ordered edge metadata and that the spine is not addressable. Zero cost, but then basic#list-1..4 stay registered permanently and the round-trip claim needs a caveat.

My own lean is that (1) should be fixed as a bug now under any of these, and that the choice between materialize and divergence is a product call about whether we want to claim RDF round-trip fidelity. Happy to be argued out of splitting it that way.

Starting points

  • fluree-graph-turtle/src/parser.rs:820-866 — the IndexedItems branch and the Nil no-op.
  • fluree-graph-turtle/src/options.rs:14-40 — the two styles, already documented.
  • fluree-db-transact/src/import.rs:183, :535, :910 — the ingest call sites that would opt in.
  • Register entries basic#list-1..4 in testsuite-sparql/tests/registers/mod.rs come off whichever way this lands, so the both-way CI check will keep us honest.

Related: the same ParserOptions default also canonicalizes numeric lexical forms at ingest (D-11) — filed separately.

Activity

  1. added
    bug
    P1
    triage:needs-decision
    area:sparql
    on Aug 26, 2026
  2. removed
    triage:needs-decision
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:sparqlbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions