inline problem_details builder at call sites; drop the one-caller wrapper
This commit is contained in:
parent
cdf1bfe7db
commit
2b0c51badf
8 changed files with 79 additions and 78 deletions
|
|
@ -12,7 +12,9 @@ use axum::{
|
|||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{AppState, guard_agent_name, problem_response, strip_container_prefix};
|
||||
use problem_details::ProblemDetails;
|
||||
|
||||
use super::{AppState, guard_agent_name, strip_container_prefix};
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(super) struct ToolGroupsSnapshot {
|
||||
|
|
@ -120,10 +122,9 @@ pub(super) async fn post_tool_groups(
|
|||
// Validate group names before queuing — fail fast so the operator
|
||||
// sees the error immediately rather than waiting for the worker.
|
||||
if let Err(e) = crate::tool_groups::validate_groups(&body.groups) {
|
||||
return problem_response(
|
||||
StatusCode::BAD_REQUEST,
|
||||
&format!("invalid tool-groups for {logical}: {e}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
|
||||
.with_detail(format!("invalid tool-groups for {logical}: {e}"))
|
||||
.into_response();
|
||||
}
|
||||
// Enqueue a PermChange so the JSON file write is serialised through
|
||||
// the FIFO worker. Prevents concurrent batch-apply actions for
|
||||
|
|
@ -207,10 +208,9 @@ pub(super) async fn post_capabilities(
|
|||
.collect();
|
||||
for cap in &body.caps {
|
||||
if !known.contains(&cap.as_str()) {
|
||||
return problem_response(
|
||||
StatusCode::BAD_REQUEST,
|
||||
&format!("unknown capability: {cap}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
|
||||
.with_detail(format!("unknown capability: {cap}"))
|
||||
.into_response();
|
||||
}
|
||||
}
|
||||
// Enqueue a PermChange so the JSON file write is serialised through
|
||||
|
|
@ -278,18 +278,16 @@ pub(super) async fn post_permissions(
|
|||
if let Some(groups) = &change.tool_groups
|
||||
&& let Err(e) = crate::tool_groups::validate_groups(groups)
|
||||
{
|
||||
return problem_response(
|
||||
StatusCode::BAD_REQUEST,
|
||||
&format!("invalid tool-groups for {logical}: {e}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
|
||||
.with_detail(format!("invalid tool-groups for {logical}: {e}"))
|
||||
.into_response();
|
||||
}
|
||||
if let Some(caps) = &change.capabilities {
|
||||
for cap in caps {
|
||||
if !known_caps.contains(&cap.as_str()) {
|
||||
return problem_response(
|
||||
StatusCode::BAD_REQUEST,
|
||||
&format!("unknown capability for {logical}: {cap}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
|
||||
.with_detail(format!("unknown capability for {logical}: {cap}"))
|
||||
.into_response();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue