Skip to content

Commit 2f1dffe

Browse files
jordanhunt22Convex, Inc.
authored andcommitted
[Open Source] Make chef deploy secret required (#41033)
GitOrigin-RevId: ddad380da1801823257085103d912ca1f6364916
1 parent 7656bb9 commit 2f1dffe

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

crates/common/src/http/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,15 +1109,19 @@ where
11091109
pub const CONVEX_CHEF_DEPLOY_SECRET_HEADER: HeaderName =
11101110
HeaderName::from_static("convex-chef-deploy-secret");
11111111

1112-
pub struct ExtractChefDeploySecret(pub Option<String>);
1112+
pub struct ExtractChefDeploySecret(pub String);
11131113

1114-
fn chef_deploy_secret_from_req_parts(parts: &mut axum::http::request::Parts) -> Option<String> {
1115-
// TODO(jordan): Once chef is pushed, this should no longer be optional and we
1116-
// should throw an error if it's not present
1114+
fn chef_deploy_secret_from_req_parts(
1115+
parts: &mut axum::http::request::Parts,
1116+
) -> anyhow::Result<String> {
11171117
parts
11181118
.headers
11191119
.get(CONVEX_CHEF_DEPLOY_SECRET_HEADER)
11201120
.and_then(|h| h.to_str().ok().map(|s| s.to_string()))
1121+
.context(ErrorMetadata::bad_request(
1122+
"InvalidChefDeploySecret",
1123+
"convex-chef-deploy-secret header is not set",
1124+
))
11211125
}
11221126

11231127
impl<S> FromRequestParts<S> for ExtractChefDeploySecret
@@ -1130,7 +1134,7 @@ where
11301134
parts: &mut axum::http::request::Parts,
11311135
_state: &S,
11321136
) -> Result<Self, Self::Rejection> {
1133-
let shared_secret = chef_deploy_secret_from_req_parts(parts);
1137+
let shared_secret = chef_deploy_secret_from_req_parts(parts)?;
11341138
Ok(Self(shared_secret))
11351139
}
11361140
}

0 commit comments

Comments
 (0)