Skip to content

Commit 5bd0473

Browse files
committed
web/builds: report unconfigured endpoint as Unauthorized
1 parent 76d1aa6 commit 5bd0473

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/web/builds.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ pub(crate) async fn build_trigger_rebuild_handler(
163163
config
164164
.trigger_rebuild_token
165165
.as_ref()
166-
.ok_or(JsonAxumNope(AxumNope::InternalError(anyhow!(
167-
"access token `trigger_rebuild_token` \
168-
is not configured"
169-
))))?;
166+
.ok_or(JsonAxumNope(AxumNope::Unauthorized(
167+
"Endpoint is not configured",
168+
)))?;
170169

171170
// (Future: would it be better to have standard middleware handle auth?)
172171
let TypedHeader(auth_header) = opt_auth_header.ok_or(JsonAxumNope(AxumNope::Unauthorized(
@@ -378,14 +377,14 @@ mod tests {
378377

379378
{
380379
let response = env.frontend().post("/crate/regex/1.3.1/rebuild").send()?;
381-
assert_eq!(response.status(), StatusCode::INTERNAL_SERVER_ERROR);
380+
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
382381
let text = response.text()?;
383382
let json: serde_json::Value = serde_json::from_str(&text)?;
384383
assert_eq!(
385384
json,
386385
serde_json::json!({
387-
"title": "Internal Server Error",
388-
"message": "access token `trigger_rebuild_token` is not configured"
386+
"title": "Unauthorized",
387+
"message": "Endpoint is not configured"
389388
})
390389
);
391390
}

0 commit comments

Comments
 (0)