Skip to content

Remote mount: branchless lookup key poisons ledger load with legacy index-root addresses; failed load is cached until container recycle #1540

Closed

Description

@jakep36

Observed on a deployed consumer stack (Solo) querying a catalog-mounted remote dataset through ProxyNameService + ProxyStorage::Raw at rev c1b1265. Queries against the mounted alias failed with:

Query error: Ledger error: Core error: Not found: fluree:proxy://<prefix>/<ledger>/index/roots/<hex>.json

while the origin demonstrably had the index root and served it over GET /storage/objects/{cid}?ledger=<ledger>:main (verified with the same bearer token; the failing hex is exactly the digest of the ns record's advertised index_head_id, codec 0x30000f).

Address anatomy of the failure

The error address has three tells: legacy .json extension, no branch segment, and the consumer-local mount prefix. That is the shape produced by legacy_index_root_address when the ledger id carries no branch:

/// Index roots were stored with a `.json` extension before the switch to `.fir6`.
/// Returns `None` for non-IndexRoot CIDs.
fn legacy_index_root_address(&self, id: &ContentId) -> Option<String> {
if id.codec() != crate::CODEC_FLUREE_INDEX_ROOT {
return None;
}
let prefix = ledger_id_prefix_for_path(&self.ledger_id);
let hex = id.digest_hex();
Some(format!(
"fluree:{}://{}/index/roots/{}.json",
self.method, prefix, hex
))
}

which is only reached after the primary (modern .fir6) read returns NotFound in ContentStore::get:

async fn get(&self, id: &ContentId) -> Result<Vec<u8>> {
let address = self.cid_to_address(id)?;
match self.storage.read_bytes(&address).await {
Ok(bytes) => return Ok(bytes),
Err(crate::error::Error::NotFound(_)) => {}
Err(e) => return Err(e),
}
// Fallback: dicts moved from per-branch to @shared namespace
if let Some(legacy) = self.legacy_dict_address(id) {
return self.storage.read_bytes(&legacy).await;
}
// Fallback: index roots stored with .json before .fir6 rename
if let Some(legacy) = self.legacy_index_root_address(id) {
return self.storage.read_bytes(&legacy).await;
}
Err(crate::error::Error::not_found(address))
}

Mechanism

  1. NsRecordResponse::into_ns_record sets ledger_id: lookup_key.to_string() verbatim. When the mount is resolved from a branchless alias (clients commonly query from: <prefix>/<ledger> with no :branch), the resulting NsRecord.ledger_id has no branch:

fn into_ns_record(self, lookup_key: &str) -> NsRecord {
use fluree_db_core::ContentId;
let derived_name = self.name.unwrap_or_else(|| {
lookup_key
.split_once(':')
.map(|(name, _branch)| name.to_string())
.unwrap_or_else(|| lookup_key.to_string())
});
NsRecord {
// ledger_id is the key used for lookup (may differ from name)
ledger_id: lookup_key.to_string(),
name: derived_name,

  1. content_path / ledger_id_prefix_for_path then derive the index-root address without the branch segment: <prefix>/<ledger>/index/roots/<hex>.fir6 instead of <prefix>/<ledger>/main/index/roots/<hex>.fir6.

  2. ProxyStorage's reverse-parser assumes the last alias segment is the branch, so the branchless path mis-splits into name=<prefix>, branch=<ledger> — the mount prefix can't be stripped (<prefix>:<ledger> has no <prefix>/ to strip), and the origin is asked for ?ledger=<prefix>:<ledger>:

fn cid_and_ledger_from_address(address: &str) -> Option<(ContentId, String)> {
// Strip `fluree:{method}://` prefix
let rest = address.strip_prefix("fluree:")?;
let sep_pos = rest.find("://")?;
let path = &rest[sep_pos + 3..];
let parts: Vec<&str> = path.split('/').collect();
let n = parts.len();
if n < 3 {
return None;
}
// Extract hash hex from the filename stem (before extension)
let filename = parts[n - 1];
let (hash_hex, _ext) = filename.rsplit_once('.')?;
// Determine the multicodec and the alias slice `parts[alias_start..alias_end]`
// based on directory structure. These patterns mirror those generated by
// `content_path()` in fluree-db-core. `alias_start` is 0 for the usual
// "{ledger}/…" layouts and 1 for the graph-source kinds, whose addresses
// lead with a literal `graph-sources` segment and carry the ledger *after*
// it. `branch_in_path` is false only for the @shared dict layout, whose
// addresses carry the ledger name with no branch segment.
let (codec, alias_start, alias_end, branch_in_path) = if n >= 2 && parts[n - 2] == "commit" {
(CODEC_FLUREE_COMMIT, 0, n - 2, true)
} else if n >= 2 && parts[n - 2] == "txn" {
(CODEC_FLUREE_TXN, 0, n - 2, true)
} else if n >= 2 && parts[n - 2] == "config" {
(CODEC_FLUREE_LEDGER_CONFIG, 0, n - 2, true)
} else if n >= 3 && parts[n - 3] == "index" && parts[n - 2] == "roots" {
(CODEC_FLUREE_INDEX_ROOT, 0, n - 3, true)

  1. The origin rejects the out-of-scope ledger, and both 404 and 403 are mapped to NotFound (deliberate no-existence-leak parity):

// 403 → NotFound parity with the server's no-existence-leak behavior
StatusCode::NOT_FOUND | StatusCode::FORBIDDEN => Err(CoreError::not_found(address)),
StatusCode::UNAUTHORIZED => Err(CoreError::storage(format!(

  1. get() falls through to the legacy .json address, which also fails, and that address surfaces in the user-facing error — pointing away from the actual cause.

Verified both directions against a live origin: reading the branch-qualified .fir6 address through ProxyStorage::Raw succeeds (the reverse-parser round-trips it correctly); the branchless forms fail exactly as above.

Second defect: the failed load sticks

The failure was reproducible on the same warm Lambda container for ~90 minutes (every query against the mounted alias failed identically), then disappeared on fresh containers — after which all queries, including the same failing one, succeed. So whatever state the connect-time race produced was retained by connection-level ledger caching rather than retried. A failed/half-built mounted-ledger load should not be cached indefinitely.

Suggested fixes

  1. into_ns_record: branch-qualify the ledger id when the lookup key lacks one — the server response carries branch, so ledger_id = format!("{lookup_key}:{branch}") (or normalize the lookup key before it's used as an id). This removes the branchless-address class entirely.
  2. Defensively, cid_and_ledger_from_address could refuse to treat a path as branch-bearing when doing so makes the prefix-strip impossible, but fix (1) is the real one.
  3. Ledger cache: don't retain a load that failed on a mount transport error; retry on next access.

Test-coverage note: the existing round-trip tests (e.g. proxy_storage.rs tests and consumers' e2e suites) use branch-qualified aliases like <prefix>/movies:main, which is why this survived. A branchless-alias case would have caught it.

Activity

  1. added
    P1
    area:storage
    on Aug 25, 2026
  2. added a commit that references this issue on Oct 4, 2026
    d8d776d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1area:storage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions