Repository navigation
Description
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:
db/fluree-db-core/src/storage.rs
Lines 519 to 531 in c1b1265
| /// 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:
db/fluree-db-core/src/storage.rs
Lines 552 to 568 in c1b1265
| 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
NsRecordResponse::into_ns_recordsetsledger_id: lookup_key.to_string()verbatim. When the mount is resolved from a branchless alias (clients commonly queryfrom: <prefix>/<ledger>with no:branch), the resultingNsRecord.ledger_idhas no branch:
db/fluree-db-nameservice-sync/src/proxy_nameservice.rs
Lines 69 to 82 in c1b1265
| 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, |
-
content_path/ledger_id_prefix_for_paththen derive the index-root address without the branch segment:<prefix>/<ledger>/index/roots/<hex>.fir6instead of<prefix>/<ledger>/main/index/roots/<hex>.fir6. -
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>:
db/fluree-db-nameservice-sync/src/proxy_storage.rs
Lines 101 to 131 in c1b1265
| 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) |
- The origin rejects the out-of-scope ledger, and both 404 and 403 are mapped to
NotFound(deliberate no-existence-leak parity):
db/fluree-db-nameservice-sync/src/proxy_storage.rs
Lines 326 to 328 in c1b1265
| // 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!( |
get()falls through to the legacy.jsonaddress, 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
into_ns_record: branch-qualify the ledger id when the lookup key lacks one — the server response carriesbranch, soledger_id = format!("{lookup_key}:{branch}")(or normalize the lookup key before it's used as an id). This removes the branchless-address class entirely.- Defensively,
cid_and_ledger_from_addresscould refuse to treat a path as branch-bearing when doing so makes the prefix-strip impossible, but fix (1) is the real one. - 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
fix: parse ledger ids once at the edge and key everything by a typed id