-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
Always stringify collection requirement versions #81694
base: devel
Are you sure you want to change the base?
Always stringify collection requirement versions #81694
Conversation
Before this change, whenever a numeric version was specified in `requirements.yml`, the YAML parser would read it as `int` or `float` which would leak straight down into the dependency resolver. This patch makes an unconditional conversion of that data into `str` right before constructing `Requirement` objects. Fixes ansible#79109 Fixes ansible#78067
@@ -310,6 +310,8 @@ def from_string(cls, collection_input, artifacts_manager, supplemental_signature | |||
def from_requirement_dict(cls, collection_req, art_mgr, validate_signature_options=True): | |||
req_name = collection_req.get('name', None) | |||
req_version = collection_req.get('version', '*') | |||
if req_version is not None: | |||
req_version = str(req_version) |
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.
@s-hertel have you considered just doing this bare minimum?
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.
I don't think it's applying to all the potential matches in the provider, is it? Needs some tests, have no idea if/what issues this is fixing.
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.
Yeah, I know about the tests. I was just pulling some things from my git stash
and turning them into draft PRs so they don't rot there.
This is an attempt to address the case when requirements.yml
has a version that is parsed by PyYAML as an int or a float causing TypeError tracebacks when some logic down the line assumes the ver
attribute is always a string, calling str
methods.
Before this change, whenever a numeric version was specified in
requirements.yml
, the YAML parser would read it asint
orfloat
which would leak straight down into the dependency resolver. This patch makes an unconditional conversion of that data intostr
right before constructingRequirement
objects.Fixes #79109
Fixes #78067
SUMMARY
$sbj.
ISSUE TYPE
ADDITIONAL INFORMATION
N/A