Add additional 404 handling for when branch and action are not in dictionary

main
drunkendog 2023-09-25 20:42:33 +01:00
parent 4ae6a24702
commit 9dbdb5200a
1 changed files with 6 additions and 1 deletions

7
api.py
View File

@ -49,7 +49,12 @@ async def set_badge(repo: str, new_badge: str, branch: str=None, action: str=Non
@app.get("/get_badge/") @app.get("/get_badge/")
async def get_badge(repo: str, branch: str=None, action: str=None): async def get_badge(repo: str, branch: str=None, action: str=None):
if repo not in badge_dict.keys(): if branch is None and action is None and repo not in badge_dict.keys():
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Repo not found",
)
elif (repo, branch, action) not in badge_dict.keys():
raise HTTPException( raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, status_code=status.HTTP_404_NOT_FOUND,
detail="Repo not found", detail="Repo not found",