Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
feat: Improves request validation
Browse files Browse the repository at this point in the history
  • Loading branch information
frgfm committed Nov 7, 2023
1 parent 4ef7b45 commit cbc3cbf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/api/api_v1/endpoints/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ async def reorder_repo_guidelines(
user=Security(get_current_user, scopes=[UserScope.USER, UserScope.ADMIN]),
) -> List[Guideline]:
telemetry_client.capture(user.id, event="guideline-order", properties={"repo_id": repo_id})
# Check the repo
await repos.get(repo_id, strict=True)
# Ensure all IDs are unique
if len(payload.guideline_ids) != len(set(payload.guideline_ids)):
raise HTTPException(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail="Duplicate IDs were passed.")
# Check the repo
await repos.get(repo_id, strict=True)
# Ensure all IDs are valid
guideline_ids = [elt.id for elt in await guidelines.fetch_all(("repo_id", repo_id))]
if set(payload.guideline_ids) != set(guideline_ids):
Expand Down

0 comments on commit cbc3cbf

Please sign in to comment.