aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-11 12:27:19 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-11 12:27:19 +0100
commitbba13f40fc2e411347ea83960935b39cedb0a7c4 (patch)
treeaefe6849f34e458ec562b7d8379c52c8fcc037a0 /src/api
parentba384e61c0951036b0c4fb394011f3498abf67ca (diff)
downloadgarage-bba13f40fc2e411347ea83960935b39cedb0a7c4.tar.gz
garage-bba13f40fc2e411347ea83960935b39cedb0a7c4.zip
Correctly return bad requests when seeh marker is invalid
Diffstat (limited to 'src/api')
-rw-r--r--src/api/k2v/batch.rs6
-rw-r--r--src/api/k2v/item.rs10
2 files changed, 5 insertions, 11 deletions
diff --git a/src/api/k2v/batch.rs b/src/api/k2v/batch.rs
index be3fba07..844faf89 100644
--- a/src/api/k2v/batch.rs
+++ b/src/api/k2v/batch.rs
@@ -24,11 +24,7 @@ pub async fn handle_insert_batch(
let mut items2 = vec![];
for it in items {
- let ct = it
- .ct
- .map(|s| CausalContext::parse(&s))
- .transpose()
- .ok_or_bad_request("Invalid causality token")?;
+ let ct = it.ct.map(|s| CausalContext::parse_helper(&s)).transpose()?;
let v = match it.v {
Some(vs) => {
DvvsValue::Value(base64::decode(vs).ok_or_bad_request("Invalid base64 value")?)
diff --git a/src/api/k2v/item.rs b/src/api/k2v/item.rs
index ebf34723..e7385bcc 100644
--- a/src/api/k2v/item.rs
+++ b/src/api/k2v/item.rs
@@ -133,9 +133,8 @@ pub async fn handle_insert_item(
.get(X_GARAGE_CAUSALITY_TOKEN)
.map(|s| s.to_str())
.transpose()?
- .map(CausalContext::parse)
- .transpose()
- .ok_or_bad_request("Invalid causality token")?;
+ .map(CausalContext::parse_helper)
+ .transpose()?;
let body = hyper::body::to_bytes(req.into_body()).await?;
let value = DvvsValue::Value(body.to_vec());
@@ -169,9 +168,8 @@ pub async fn handle_delete_item(
.get(X_GARAGE_CAUSALITY_TOKEN)
.map(|s| s.to_str())
.transpose()?
- .map(CausalContext::parse)
- .transpose()
- .ok_or_bad_request("Invalid causality token")?;
+ .map(CausalContext::parse_helper)
+ .transpose()?;
let value = DvvsValue::Deleted;