fix: update HTTP status code from UNPROCESSABLE_ENTITY to UNPROCESSABLE_CONTENT
This commit is contained in:
@@ -208,7 +208,7 @@ class GatewayAdminLifecycleService(OpenClawDBService):
|
||||
)
|
||||
if template_user is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Organization owner not found (required for gateway agent USER.md rendering).",
|
||||
)
|
||||
raw_token = mint_agent_token(agent)
|
||||
|
||||
@@ -184,7 +184,7 @@ class GatewayCoordinationService(AbstractGatewayMessagingService):
|
||||
target = await self._board_agent_or_404(board=board, agent_id=target_agent_id)
|
||||
if not target.openclaw_session_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Target agent has no session key",
|
||||
)
|
||||
_gateway, config = await GatewayDispatchService(
|
||||
@@ -335,7 +335,7 @@ class GatewayCoordinationService(AbstractGatewayMessagingService):
|
||||
normalized_content = content.strip()
|
||||
if not normalized_content:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="content is required",
|
||||
)
|
||||
|
||||
@@ -541,7 +541,7 @@ class GatewayCoordinationService(AbstractGatewayMessagingService):
|
||||
)
|
||||
if not lead.openclaw_session_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Lead agent has no session key",
|
||||
)
|
||||
await self._dispatch_gateway_message(
|
||||
|
||||
@@ -28,7 +28,7 @@ def gateway_client_config(gateway: Gateway) -> GatewayClientConfig:
|
||||
url = (gateway.url or "").strip()
|
||||
if not url:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Gateway url is required",
|
||||
)
|
||||
token = (gateway.token or "").strip() or None
|
||||
@@ -51,7 +51,7 @@ def require_gateway_workspace_root(gateway: Gateway) -> str:
|
||||
workspace_root = (gateway.workspace_root or "").strip()
|
||||
if not workspace_root:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Gateway workspace_root is required",
|
||||
)
|
||||
return workspace_root
|
||||
@@ -82,13 +82,13 @@ async def require_gateway_for_board(
|
||||
"""Return a board's gateway or raise a 422 with a stable error message."""
|
||||
if board.gateway_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Board gateway_id is required",
|
||||
)
|
||||
gateway = await get_gateway_for_board(session, board)
|
||||
if gateway is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Board gateway_id is invalid",
|
||||
)
|
||||
if require_workspace_root:
|
||||
|
||||
@@ -63,7 +63,7 @@ class OpenClawAuthorizationPolicy:
|
||||
def require_gateway_configured(gateway: Gateway) -> None:
|
||||
if not gateway.url:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Gateway url is required",
|
||||
)
|
||||
|
||||
|
||||
@@ -755,7 +755,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
if existing:
|
||||
return existing
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Gateway main agent session key is required",
|
||||
)
|
||||
if agent.is_board_lead:
|
||||
@@ -766,7 +766,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
def workspace_path(cls, agent_name: str, workspace_root: str | None) -> str:
|
||||
if not workspace_root:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Gateway workspace_root is required",
|
||||
)
|
||||
root = workspace_root.rstrip("/")
|
||||
@@ -781,7 +781,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
) -> Board:
|
||||
if not board_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_id is required",
|
||||
)
|
||||
board = await Board.objects.by_id(board_id).first(self.session)
|
||||
@@ -1070,7 +1070,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
)
|
||||
if template_user is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=(
|
||||
"User context is required to provision the gateway main agent "
|
||||
"(org owner not found)."
|
||||
@@ -1220,7 +1220,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
elif make_main is not None:
|
||||
if "board_id" not in updates or updates["board_id"] is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=(
|
||||
"board_id is required when converting a gateway-main agent "
|
||||
"to board scope"
|
||||
@@ -1229,7 +1229,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
board = await self.require_board(updates["board_id"])
|
||||
if board.gateway_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Board gateway_id is required",
|
||||
)
|
||||
updates["gateway_id"] = board.gateway_id
|
||||
@@ -1239,7 +1239,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
board = await self.require_board(updates["board_id"])
|
||||
if board.gateway_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Board gateway_id is required",
|
||||
)
|
||||
updates["gateway_id"] = board.gateway_id
|
||||
@@ -1254,7 +1254,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
board = await self.require_board(agent.board_id)
|
||||
if board.gateway_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Board gateway_id is required",
|
||||
)
|
||||
agent.gateway_id = board.gateway_id
|
||||
@@ -1277,7 +1277,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
if make_main:
|
||||
if gateway_for_main is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Gateway agent requires a gateway configuration",
|
||||
)
|
||||
return AgentUpdateProvisionTarget(
|
||||
@@ -1295,7 +1295,7 @@ class AgentLifecycleService(OpenClawDBService):
|
||||
|
||||
if agent.board_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_id is required for non-main agents",
|
||||
)
|
||||
board = await self.require_board(agent.board_id)
|
||||
|
||||
@@ -101,7 +101,7 @@ class GatewaySessionService(OpenClawDBService):
|
||||
raw_url = params.gateway_url.strip()
|
||||
if not raw_url:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_id or gateway_url is required",
|
||||
)
|
||||
return (
|
||||
@@ -114,7 +114,7 @@ class GatewaySessionService(OpenClawDBService):
|
||||
)
|
||||
if not params.board_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_id or gateway_url is required",
|
||||
)
|
||||
board = await Board.objects.by_id(params.board_id).first(self.session)
|
||||
@@ -144,7 +144,7 @@ class GatewaySessionService(OpenClawDBService):
|
||||
board, config, main_session = await self.resolve_gateway(params, user=user)
|
||||
if board is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_id is required",
|
||||
)
|
||||
return board, config, main_session
|
||||
|
||||
Reference in New Issue
Block a user