fix: query a graph source by alias instead of loading it as a ledger#1375
fix: query a graph source by alias instead of loading it as a ledger#1375bplatz wants to merge 5 commits into
Conversation
…1369) Querying a registered Iceberg/R2RML graph source by alias (`POST /v1/fluree/query/<alias>`) returned 500 `Serialization error: missing field f:ledger`: the file nameservice's `lookup` deserialized the graph-source record as a ledger `NsFileV2`, and the ledger-query path had no graph-source fallback. - `FileNameService::lookup` now skips graph-source records (the guard `list_branches`/`all_records` already use), returning `None` so the alias resolves as "no ledger here" instead of crashing on the missing `f:ledger`. - The ledger-query route falls back to the connection/dataset path on a not-found ledger, which resolves the alias as a graph source and queries it via its source engine (the same fallback `load_view_from_source` already uses). Regression tests: a nameservice unit test (lookup of a graph-source alias must not error) and a server integration test (alias query must not fail deserializing the record as a ledger).
|
Hi there! I can confirme this removes the Testing the branch against a readable Iceberg/R2RML graph source, querying by alias still didn't return rows. Digging in, completing #1369 needs three pieces — #1375 has part of (1); here are all three, each verified to return rows: 1. Nameservice
|
…/graph-source-alias-query
Finishes the alias-query support started in #1375, addressing the reporter's follow-up findings: - StorageNameService::lookup: add the same graph-source guard FileNameService::lookup already has, so the storage backend no longer 500s ("missing field `f:ledger`") when an alias names a graph source. - execute_sparql_ledger: the single-target SPARQL alias path had no graph-source fallback (the JSON-LD path already falls back to the dataset path). On a not-found ledger it now resolves via graph(alias).query() (auto-enables R2RML), returning JSON. - FromQueryBuilder formatter: result formatting re-resolved the alias via db(), which is ledger-only and 500s for a graph source. Add db_or_graph_source (db() with a graph-source fallback) and use it at the six formatter sites, fixing SPARQL FROM <graph-source>. Consolidate the genesis graph-source view logic into a single Fluree::resolve_graph_source; resolve_as_graph_source and db_or_graph_source delegate to it. Remove the unused load_graph_db_or_graph_source. Tests: storage-backend lookup regression (nameservice); strengthen the server alias test to assert it routes to the graph-source engine rather than 404 / deserialize as a ledger.
|
Thanks @christophediprima -- that helped flesh out the remaining issues and should be all addressed now. |
Closes #1369.
Problem
Querying a registered Iceberg/R2RML graph source by alias
(
POST /v1/fluree/query/<alias>) returned a 500:Registration,
fluree list, andfluree infoall worked — only the directquery failed, and it failed during alias resolution (before the catalog was
ever read). Querying the same source through the dataset path (
from: <alias>)worked, so the bug was specific to the alias-in-URL query route.
Root cause
Two gaps on the alias-query path:
FileNameService::lookuphad no graph-source guard. It deserialized thenameservice record as a ledger
NsFileV2, but a graph source is stored as aGraphSourceNsFileV2(nof:ledgerfield), so the deserialize failed. Thesibling methods
list_branchesandall_recordsalready skip graph-sourcerecords via
is_graph_source_record;lookupwas missing the same check.The ledger-query route had no graph-source fallback. It loaded the alias
strictly as a ledger. The dataset path already handles this
(
load_view_from_sourcefalls back toresolve_as_graph_source); thealias-in-URL path did not.
Fix
FileNameService::lookupnow skips graph-source records (the same guardlist_branches/all_recordsuse), returningNoneso the alias resolves as"no ledger here" instead of erroring on the missing
f:ledger.not-found ledger, which resolves the alias as a graph source and queries it
via its source engine — the same fallback the dataset path already uses.
Tests
fluree-db-nameservice: a unit test thatlookupof a graph-source aliasreturns
Nonerather than erroring (reproduces the exactmissing field f:ledgerfailure before the fix).fluree-db-server: an integration test that registers an R2RML graph sourceand queries it by alias, asserting the response no longer fails by
deserializing the record as a ledger.
The existing nameservice and server query suites pass unchanged; the memory
nameservice was unaffected (it stores graph sources in a separate map).
Reviewers: @aaj3f @zonotope