Skip to content

Build and run agents you can see, understand and trust.

fix(app): replace deprecated HTTP 422 status constants- #3479、 (#3479)

Felix Shifebc29ab0434
diff --git a/src/agentscope/app/_router/_agent.py b/src/agentscope/app/_router/_agent.py
index c78a7e16f..3b1580775 100644
--- a/src/agentscope/app/_router/_agent.py
+++ b/src/agentscope/app/_router/_agent.py
@@ -203,7 +203,7 @@ async def create_agent(
data = AgentData.model_validate(body.model_dump(exclude_none=True))
except ValidationError as exc:
raise HTTPException(
- status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=exc.errors(),
) from exc
record = AgentRecord(user_id=user_id, data=data)
@@ -270,7 +270,7 @@ async def update_agent(
)
except ValidationError as exc:
raise HTTPException(
- status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=exc.errors(),
) from exc
updated_agent = existing.model_copy(
diff --git a/src/agentscope/app/_router/_sop.py b/src/agentscope/app/_router/_sop.py
index 01b838c19..e4b3be2dc 100644
--- a/src/agentscope/app/_router/_sop.py
+++ b/src/agentscope/app/_router/_sop.py
@@ -449,6 +449,6 @@ def _reject_unconfigured_sessions(data: SOPData) -> None:
)
except ValueError as exc:
raise HTTPException(
- status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=str(exc),
) from exc
diff --git a/src/agentscope/app/_router/_workspace.py b/src/agentscope/app/_router/_workspace.py
index 3f5055b75..6e3b43f6f 100644
--- a/src/agentscope/app/_router/_workspace.py
+++ b/src/agentscope/app/_router/_workspace.py
@@ -293,7 +293,7 @@ async def upload_skill(
workspace_service.validate_manifest(parsed, len(files))
except (ValidationError, SkillUploadError) as e:
raise HTTPException(
- status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status.HTTP_422_UNPROCESSABLE_CONTENT,
str(e),
) from e
@@ -314,7 +314,7 @@ async def upload_skill(
)
except (SkillUploadError, ValueError) as e:
raise HTTPException(
- status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status.HTTP_422_UNPROCESSABLE_CONTENT,
str(e),
) from e
diff --git a/src/agentscope/app/_service/_knowledge_base.py b/src/agentscope/app/_service/_knowledge_base.py
index a2d12b62d..7762714a0 100644
--- a/src/agentscope/app/_service/_knowledge_base.py
+++ b/src/agentscope/app/_service/_knowledge_base.py
@@ -159,7 +159,7 @@ class KnowledgeBaseService:
chunker_cls = self._chunkers_by_type.get(chunker_config.type)
if chunker_cls is None:
raise HTTPException(
- status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=(
f"Unknown chunker type: {chunker_config.type!r}, "
f"available: {sorted(self._chunkers_by_type)}"
@@ -169,7 +169,7 @@ class KnowledgeBaseService:
chunker_cls.Parameters(**chunker_config.parameters)
except (TypeError, ValueError, ValidationError) as exc:
raise HTTPException(
- status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+ status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=f"Invalid chunker parameters: {exc}",
) from exc