Skip to content

Commit

Permalink
[BugFix] Add try-except to AWS credentials API (#4261)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchhablani authored Jan 29, 2024
1 parent 0629ac9 commit 7b6bf3b
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions apps/challenges/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,24 +2830,28 @@ def get_aws_credentials_for_participant_team(request, phase_pk):
- When participant_team has not participanted in challenge
- When Challenge is not Docker based
"""
challenge_phase = get_challenge_phase_model(phase_pk)
challenge = challenge_phase.challenge
participant_team = get_participant_team_of_user_for_a_challenge(
request.user, challenge.pk
)
if not challenge.is_docker_based:
response_data = {
"error": "Sorry, this is not a docker based challenge."
}
return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
try:
challenge_phase = get_challenge_phase_model(phase_pk)
challenge = challenge_phase.challenge
participant_team = get_participant_team_of_user_for_a_challenge(
request.user, challenge.pk
)
if not challenge.is_docker_based:
response_data = {
"error": "Sorry, this is not a docker based challenge."
}
return Response(response_data, status=status.HTTP_400_BAD_REQUEST)

if participant_team is None:
response_data = {
"error": "You have not participated in this challenge."
}
if participant_team is None:
response_data = {
"error": "You have not participated in this challenge."
}
return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
data = get_aws_credentials_for_submission(challenge, participant_team)
response_data = {"success": data}
except Exception as e:
response_data = {"error": e}
return Response(response_data, status=status.HTTP_400_BAD_REQUEST)
data = get_aws_credentials_for_submission(challenge, participant_team)
response_data = {"success": data}
return Response(response_data, status=status.HTTP_200_OK)


Expand Down

0 comments on commit 7b6bf3b

Please sign in to comment.