fix: update HTTP status code from UNPROCESSABLE_ENTITY to UNPROCESSABLE_CONTENT
This commit is contained in:
@@ -783,7 +783,7 @@ async def delete_task(
|
||||
_guard_task_access(agent_ctx, task)
|
||||
_require_board_lead(agent_ctx)
|
||||
if task.board_id is None:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
await tasks_api.delete_task_and_related_records(session, task=task)
|
||||
return OkResponse()
|
||||
|
||||
|
||||
@@ -600,7 +600,7 @@ async def create_board_group_memory_for_board(
|
||||
group_id = board.board_group_id
|
||||
if group_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Board is not in a board group",
|
||||
)
|
||||
group = await BoardGroup.objects.by_id(group_id).first(session)
|
||||
|
||||
@@ -160,7 +160,7 @@ async def get_board_group_snapshot(
|
||||
write=False,
|
||||
)
|
||||
if per_board_task_limit < 0:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
snapshot = await build_group_snapshot(
|
||||
session,
|
||||
group=group,
|
||||
|
||||
@@ -262,7 +262,7 @@ async def _validate_agent_id(
|
||||
agent = await Agent.objects.filter_by(id=agent_id, board_id=board.id).first(session)
|
||||
if agent is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="agent_id must reference an agent on this board.",
|
||||
)
|
||||
|
||||
|
||||
@@ -69,12 +69,12 @@ async def _require_gateway(
|
||||
gateway = await crud.get_by_id(session, Gateway, gateway_id)
|
||||
if gateway is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="gateway_id is invalid",
|
||||
)
|
||||
if organization_id is not None and gateway.organization_id != organization_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="gateway_id is invalid",
|
||||
)
|
||||
return gateway
|
||||
@@ -101,12 +101,12 @@ async def _require_board_group(
|
||||
group = await crud.get_by_id(session, BoardGroup, board_group_id)
|
||||
if group is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_group_id is invalid",
|
||||
)
|
||||
if organization_id is not None and group.organization_id != organization_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="board_group_id is invalid",
|
||||
)
|
||||
return group
|
||||
@@ -153,12 +153,12 @@ async def _apply_board_update(
|
||||
if updates.get("board_type") == "goal" and (not board.objective or not board.success_metrics):
|
||||
# Validate only when explicitly switching to goal boards.
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Goal boards require objective and success_metrics",
|
||||
)
|
||||
if not board.gateway_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="gateway_id is required",
|
||||
)
|
||||
board.updated_at = utcnow()
|
||||
|
||||
@@ -127,7 +127,7 @@ async def create_organization(
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
|
||||
name = payload.name.strip()
|
||||
if not name:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
existing = (
|
||||
await session.exec(
|
||||
select(Organization).where(
|
||||
@@ -513,7 +513,7 @@ async def update_member_access(
|
||||
.all(session)
|
||||
}
|
||||
if valid_board_ids != board_ids:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
|
||||
await apply_member_access_update(session, member=member, update=payload)
|
||||
await session.commit()
|
||||
@@ -614,7 +614,7 @@ async def create_org_invite(
|
||||
"""Create an organization invite for an email address."""
|
||||
email = normalize_invited_email(payload.invited_email)
|
||||
if not email:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
|
||||
existing_user = (
|
||||
await session.exec(select(User).where(func.lower(col(User.email)) == email))
|
||||
@@ -654,7 +654,7 @@ async def create_org_invite(
|
||||
.all(session)
|
||||
}
|
||||
if valid_board_ids != board_ids:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
await apply_invite_board_access(
|
||||
session,
|
||||
invite=invite,
|
||||
|
||||
@@ -25,7 +25,7 @@ def _validate_segment(value: str, *, field: str) -> str:
|
||||
cleaned = value.strip().strip("/")
|
||||
if not cleaned:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=f"{field} is required",
|
||||
)
|
||||
if field == "handle":
|
||||
@@ -34,7 +34,7 @@ def _validate_segment(value: str, *, field: str) -> str:
|
||||
ok = bool(_SAFE_SLUG_RE.match(cleaned))
|
||||
if not ok:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=f"{field} contains unsupported characters",
|
||||
)
|
||||
return cleaned
|
||||
|
||||
@@ -84,7 +84,7 @@ async def _validated_board_ids_for_org(
|
||||
normalized_board_ids = list(dict.fromkeys(board_ids))
|
||||
if not normalized_board_ids:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="At least one board must be selected.",
|
||||
)
|
||||
valid_board_ids = set(
|
||||
@@ -103,7 +103,7 @@ async def _validated_board_ids_for_org(
|
||||
)
|
||||
if missing_board_ids:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail={
|
||||
"message": "Some selected boards are invalid for this organization.",
|
||||
"invalid_board_ids": [str(value) for value in missing_board_ids],
|
||||
@@ -177,7 +177,7 @@ async def create_org_custom_field(
|
||||
)
|
||||
except ValueError as err:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=str(err),
|
||||
) from err
|
||||
definition = TaskCustomFieldDefinition(
|
||||
@@ -252,7 +252,7 @@ async def update_org_custom_field(
|
||||
)
|
||||
except ValueError as err:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail=str(err),
|
||||
) from err
|
||||
for key, value in updates.items():
|
||||
|
||||
@@ -121,7 +121,7 @@ class _BoardCustomFieldDefinition:
|
||||
|
||||
def _comment_validation_error() -> HTTPException:
|
||||
return HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Comment is required.",
|
||||
)
|
||||
|
||||
@@ -723,7 +723,7 @@ def _status_values(status_filter: str | None) -> list[str]:
|
||||
values = [s.strip() for s in status_filter.split(",") if s.strip()]
|
||||
if any(value not in ALLOWED_STATUSES for value in values):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Unsupported task status filter.",
|
||||
)
|
||||
return values
|
||||
@@ -777,7 +777,7 @@ def _reject_unknown_custom_field_keys(
|
||||
if not unknown_field_keys:
|
||||
return
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail={
|
||||
"message": "Unknown custom field keys for this board.",
|
||||
"unknown_field_keys": unknown_field_keys,
|
||||
@@ -798,7 +798,7 @@ def _reject_missing_required_custom_field_keys(
|
||||
if not missing_field_keys:
|
||||
return
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail={
|
||||
"message": "Required custom fields must have values.",
|
||||
"missing_field_keys": sorted(missing_field_keys),
|
||||
@@ -821,7 +821,7 @@ def _reject_invalid_custom_field_values(
|
||||
)
|
||||
except ValueError as err:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail={
|
||||
"message": "Invalid custom field value.",
|
||||
"field_key": field_key,
|
||||
@@ -1372,7 +1372,7 @@ async def update_task(
|
||||
"""Update task status, assignment, comment, and dependency state."""
|
||||
if task.board_id is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||
detail="Task board_id is required.",
|
||||
)
|
||||
board_id = task.board_id
|
||||
@@ -1498,7 +1498,7 @@ async def delete_task(
|
||||
) -> OkResponse:
|
||||
"""Delete a task and related records."""
|
||||
if task.board_id is None:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
board = await Board.objects.by_id(task.board_id).first(session)
|
||||
if board is None:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
|
||||
@@ -1534,7 +1534,7 @@ async def _validate_task_comment_access(
|
||||
actor: ActorContext,
|
||||
) -> None:
|
||||
if task.board_id is None:
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
|
||||
if actor.actor_type == "user" and actor.user is not None:
|
||||
board = await Board.objects.by_id(task.board_id).first(session)
|
||||
@@ -1677,13 +1677,13 @@ class _TaskUpdateInput:
|
||||
def _required_status_value(value: object) -> str:
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
|
||||
|
||||
def _optional_assigned_agent_id(value: object) -> UUID | None:
|
||||
if value is None or isinstance(value, UUID):
|
||||
return value
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY)
|
||||
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_CONTENT)
|
||||
|
||||
|
||||
async def _board_organization_id(
|
||||
|
||||
Reference in New Issue
Block a user