Fix bundle lookup: normalize fingerprints, handle 404 gracefully
Server: normalize fingerprints by stripping colons and lowercasing before storing/looking up in sled. Adds tracing for register/lookup. Client: check HTTP status before parsing JSON response body. Shows clear error when user is not registered instead of parse error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -59,7 +59,7 @@ impl ServerClient {
|
||||
|
||||
/// Fetch a user's pre-key bundle from the server.
|
||||
pub async fn fetch_bundle(&self, fingerprint: &str) -> Result<PreKeyBundle> {
|
||||
let resp: BundleResponse = self
|
||||
let response = self
|
||||
.client
|
||||
.get(format!(
|
||||
"{}/v1/keys/{}",
|
||||
@@ -67,7 +67,17 @@ impl ServerClient {
|
||||
))
|
||||
.send()
|
||||
.await
|
||||
.context("failed to fetch bundle")?
|
||||
.context("failed to fetch bundle")?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
anyhow::bail!(
|
||||
"server returned {} — user {} may not be registered",
|
||||
response.status(),
|
||||
fingerprint
|
||||
);
|
||||
}
|
||||
|
||||
let resp: BundleResponse = response
|
||||
.json()
|
||||
.await
|
||||
.context("failed to parse bundle response")?;
|
||||
|
||||
Reference in New Issue
Block a user