-
Notifications
You must be signed in to change notification settings - Fork 158
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
Handled exception from vault? method #350
Handled exception from vault? method #350
Conversation
lib/chef-vault/item.rb
Outdated
else | ||
raise http_error | ||
end | ||
rescue Chef::Exceptions::ValidationFailed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanga1794 we are raising Item not found exception in case of ValidationFailed ? So wouldn't it will raise the Item not found exception even though its a validation failure ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just took the reference from method self.load
chef-vault/lib/chef-vault/item.rb
Line 289 in 6428e99
def self.load(vault, name, opts = {}) |
lib/chef-vault/item.rb
Outdated
else | ||
raise http_error | ||
end | ||
rescue Chef::Exceptions::ValidationFailed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does validation failing always indicate that the data bag isn't there? Would't that be the 404 you're rescuing above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes @tas50, in my case only rescuing 404 will be fine, will remove the remaining, thanks
Signed-off-by: sanga17 <[email protected]>
Signed-off-by: sanga17 <[email protected]>
9c0374d
to
690cdd8
Compare
lib/chef-vault/item.rb
Outdated
rescue Net::HTTPServerException => http_error | ||
if http_error.response.code == "404" | ||
raise ChefVault::Exceptions::ItemNotFound, | ||
"#{vault}/#{name} could not be found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider "#{vault}/#{name} not found"
, unless we habitually use the polite subjunctive could not be
in our output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kagarmoe, will update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a style note, but I don't know the code base well enough to insist on it.
Signed-off-by: sanga17 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pry stack explorer needs to be pinned so these tests will pass. Here's how we're doing it in ohai:
https://github.com/chef/ohai/blob/master/Gemfile#L25
Thanks @tas50, I'll update it |
Signed-off-by: sanga17 <[email protected]>
@sanga1794 There's a simple chefstyle violation that should get corrected to get the tests green as well. |
Signed-off-by: sanga17 <[email protected]>
4eeb109
to
452611e
Compare
Thanks @sanga1794 |
Signed-off-by: sanga17 [email protected]
Description
Fixed 'vault?' method should throw meaningful exception when no data bag exists
Related Issue
Fixed: #278
Types of changes
Checklist: