Validate the graph selection in queries list

Graph-existence validation was a side effect of URI resolution: every
URI-resolving command rejects an unknown --target via resolve_target_uri, but
queries list opens no URI, so query_entries_for(Some(unknown)) silently fell
back to the top-level registry and showed the wrong (or empty) catalog.

Make membership a property of the selection: add the fallible
resolve_graph_selection alongside the infallible query_entries_for (a known
name passes through, an unknown name errors with the same message as
resolve_target_uri, None stays anonymous), and validate the selection in
execute_queries_list. query_entries_for is unchanged — server boot's bare-URI
path still needs its None -> top-level arm.
This commit is contained in:
Ragnor Comerford 2026-06-01 11:22:41 +02:00
parent fb56a31c16
commit 98831d4fa9
No known key found for this signature in database
2 changed files with 43 additions and 2 deletions

View file

@ -1787,8 +1787,12 @@ fn execute_queries_list(
) -> Result<()> {
let config = load_cli_config(config_path)?;
// `list` takes no URI, so the selection is the target or the configured
// default graph (named → its per-graph block; else top-level).
let selected = target.as_deref().or_else(|| config.cli_graph_name());
// default graph (named → its per-graph block; else top-level). Validate
// membership explicitly — every URI-resolving command rejects an unknown
// name as a side effect of `resolve_target_uri`, but `list` opens no URI,
// so it would otherwise fall back to the top-level registry silently.
let selected =
config.resolve_graph_selection(target.as_deref().or_else(|| config.cli_graph_name()))?;
let registry = load_registry_or_report(&config, selected)?;
let output = QueriesListOutput {