at protocol indexer with flexible filtering, xrpc queries, and a cursor-backed event stream, built on fjall
at-protocol atproto indexer rust fjall

[backfill] fix utf-8 error when reading binary TrimmedDid keys

ptr.pet 505a93c8 c74104c4

verified
+14 -12
+14 -12
src/backfill/mod.rs
··· 486 486 for (col_name, ks) in partitions { 487 487 for guard in ks.prefix(&prefix) { 488 488 let (key, cid_bytes) = guard.into_inner().into_diagnostic()?; 489 - // key: {DID}|{RKey} 490 - let key_str = std::str::from_utf8(&key).into_diagnostic()?; 491 - let parts: Vec<&str> = key_str.split(keys::SEP as char).collect(); 492 - if parts.len() == 2 { 493 - let rkey = parts[1].to_smolstr(); 494 - let cid = if let Ok(c) = cid::Cid::read_bytes(cid_bytes.as_ref()) { 495 - c.to_string().to_smolstr() 496 - } else { 497 - continue; 498 - }; 489 + let Some(sep_pos) = key.iter().position(|&b| b == keys::SEP) else { 490 + error!("invalid key for {did}: {key:?}"); 491 + continue; 492 + }; 493 + let rkey = std::str::from_utf8(&key[sep_pos + 1..]) 494 + .into_diagnostic()? 495 + .to_smolstr(); 496 + let cid = if let Ok(c) = cid::Cid::read_bytes(cid_bytes.as_ref()) { 497 + c.to_string().to_smolstr() 498 + } else { 499 + error!("invalid cid for {did}: {cid_bytes:?}"); 500 + continue; 501 + }; 499 502 500 - existing_cids.insert((col_name.as_str().into(), rkey), cid); 501 - } 503 + existing_cids.insert((col_name.as_str().into(), rkey), cid); 502 504 } 503 505 } 504 506