Don't crash if the client sends an invalid store path name
This commit is contained in:
parent
1835ad1c08
commit
de2b44169c
|
@ -9,7 +9,7 @@ use axum_macros::debug_handler;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::State;
|
||||
use crate::error::Result;
|
||||
use crate::error::{Error, Result};
|
||||
use crate::util::{get_store_paths, upload_paths};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
@ -112,11 +112,11 @@ async fn enqueue_paths(
|
|||
) -> Result<Json<EnqueuePathsResponse>> {
|
||||
tracing::info!("Enqueueing {:?}", req.store_paths);
|
||||
|
||||
let store_paths: Vec<_> = req
|
||||
let store_paths = req
|
||||
.store_paths
|
||||
.iter()
|
||||
.map(|path| state.store.follow_store_path(path).unwrap())
|
||||
.collect();
|
||||
.map(|path| state.store.follow_store_path(path).map_err(Error::Attic))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
if let Some(flakehub_state) = &*state.flakehub_state.read().await {
|
||||
crate::flakehub::enqueue_paths(flakehub_state, store_paths).await?;
|
||||
|
|
|
@ -345,8 +345,9 @@ async fn post_build_hook(out_paths: &str) {
|
|||
match response {
|
||||
Ok(response) if !response.status().is_success() => {
|
||||
err_message = Some(format!(
|
||||
"magic-nix-cache server failed to enqueue the push request: {}",
|
||||
response.status()
|
||||
"magic-nix-cache server failed to enqueue the push request: {}\n{}",
|
||||
response.status(),
|
||||
response.text().await.unwrap_or_else(|_| "".to_owned()),
|
||||
));
|
||||
}
|
||||
Ok(response) => {
|
||||
|
|
Loading…
Reference in a new issue