Skip to content

Commit

Permalink
fix: KV 404
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Jun 25, 2024
1 parent fec7ca9 commit 1559bc5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/attestation_store/cf_kv.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use {
super::{AttestationStore, Result},
async_trait::async_trait,
hyper::StatusCode,
serde::Serialize,
std::time::Duration,
};
Expand Down Expand Up @@ -74,13 +75,17 @@ impl AttestationStore for CloudflareKv {
.timeout(Duration::from_secs(1))
.send()
.await?;
// TODO what is the status code for a key not found?
// TODO for not-key not found errors throw error instead of None
if response.status().is_success() {
let value = response.text().await?;
Ok(Some(value))
} else {
} else if response.status() == StatusCode::NOT_FOUND {
Ok(None)
} else {
Err(anyhow::anyhow!(
"Failed to get attestation: status:{} response body:{:?}",
response.status(),
response.text().await
))
}
}
}

0 comments on commit 1559bc5

Please sign in to comment.