-
Notifications
You must be signed in to change notification settings - Fork 166
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
looking up entities with the name set to an empty string sometimes results in unexpected errors #1771
Comments
So to understand this correctly, the module is failing under the right circumstances, but for the wrong reason, right? To pick up your idea: Can we pass the def find_resource_by(self, resource, search_field, value, required=False, **kwargs):
if not value:
if required:
raise WhateverRequiredEntityNotSpecifiedError()
return NoEntity
... |
Yeah. Most importantly, it gives an ugly stack trace instead of erroring with "couldn't find resource X".
Yes, that's roughly the direction I was heading. |
Actually, I think this should be sufficient: def find_resource_by(self, resource, search_field, value, required=False, **kwargs):
if not value and not required:
return NoEntity
… As the rest of the code will already correctly error when nothing was found. |
Right. My line of thought was "Nothing found." is a different complaint than "You didn't specify a required thing.". |
Yeah… but they did specify it ("" is a specification), so imho the error "nothing found with name ''" is the correct one here. |
Fair. Can we spare a lookup request when we already know that "" will not find us anything? |
Maybe? ;-) |
SUMMARY
Because of the "empty string is special to unset things" logic introduced in f50bd16, we do not immediately fail when such an input is provided, which leads to errors in the code later on that relies on the fact that the entity was properly found.
we probably should just not apply the "empty string to unset" logic to parameters that are set as
required=True
(likecontent_view
in thecontent_view_version
module, which the example below uses).ISSUE TYPE
ANSIBLE VERSION
all
COLLECTION VERSION
since f50bd16
KATELLO/FOREMAN VERSION
all
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: