fix(hub_publish): return 400 not 500 when HUB_DEV_TOKEN is unset

Missing config is a client/config error, not a server fault. Restores the
BadRequest class lost when hub_token() was extracted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
tristantr
2026-06-10 16:35:29 +02:00
co-authored by Claude Opus 4.8
parent f8705ec56a
commit ca5c8e9717
+6 -1
View File
@@ -362,7 +362,12 @@ async fn submit_project(
}
fn hub_token() -> Result<String, Error> {
std::env::var("HUB_DEV_TOKEN").map_err(|_| Error::InternalErr("HUB_DEV_TOKEN not set".into()))
// Missing config, not a server fault: surface a clear 400 rather than a 500.
std::env::var("HUB_DEV_TOKEN").map_err(|_| {
Error::BadRequest(
"Hub publishing is not configured on this instance (HUB_DEV_TOKEN not set)".into(),
)
})
}
async fn get_from_hub(path: &str, source_id: &str) -> Result<(StatusCode, String), Error> {