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

Add error handling around SNS API calls #21

Merged
merged 5 commits into from
Apr 27, 2017

Conversation

makimoto
Copy link
Contributor

@makimoto makimoto commented Apr 27, 2017

I add error handling around SNS API calls.
In our environment we want to restrict available topics to subscribe by IAM roles. So if a user is setting a restricted topic, Barbeque returns 500 error for now.
This patch avoids 500 error and shows error messages when accessing unauthorized topic or not found.

@cookpad/dev-infra @k0kubun How do you think?

@makimoto makimoto requested a review from k0kubun April 27, 2017 07:33
@sns_topic_arns = fetch_sns_topic_arns
render :new
else
@sns_subscription.save
Copy link
Member

Choose a reason for hiding this comment

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

Use save! if you don't check the return value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@@ -50,6 +61,8 @@ def destroy

def fetch_sns_topic_arns
sns_client.list_topics.topics.map(&:topic_arn)
rescue Aws::Errors::MissingCredentialsError, Aws::SNS::Errors::AuthorizationError
Copy link
Member

Choose a reason for hiding this comment

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

I think these exceptions should be reported as 5xx error because sns:ListTopics permission is required in Barbeque

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, too. fixed.

Copy link
Collaborator

@k0kubun k0kubun left a comment

Choose a reason for hiding this comment

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

Also having tests for AuthorizationError may be better.

@makimoto
Copy link
Contributor Author

Also having tests for AuthorizationError may be better.

done.

I'll release v0.4.1. Thank you!

@makimoto makimoto merged commit 31d9bc5 into cookpad:master Apr 27, 2017
@makimoto makimoto deleted the error-handling-sns branch April 27, 2017 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants