Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: graceful error handling for robot acct already exists (PROJQUAY-6261) #2436

Merged
merged 2 commits into from Oct 31, 2023

Conversation

Sunandadadi
Copy link
Contributor

This PR takes care of graceful error handling instead of raising an exception for create robot account endpoint. Added the same error to propagate on the new UI too.

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
endpoints/api/robot.py 95.12% <100.00%> (+0.18%) ⬆️

... and 4 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@@ -121,6 +122,12 @@ def put(self, robot_shortname):
"""
parent = get_authenticated_user()
create_data = request.get_json(silent=True) or {}

if model.robot_account_exists(robot_shortname, parent, user=True) is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to catch the duplicate name error returned by create_user_robot and re-raise the request_error? That way we don't add any additional API requests. Same for the org endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point.

Copy link
Contributor

@bcaton85 bcaton85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sunandadadi Sunandadadi merged commit 21e502f into quay:master Oct 31, 2023
13 checks passed
@Sunandadadi Sunandadadi deleted the PROJQUAY-6261 branch October 31, 2023 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants