From f25437a8215dd88b6058ded629441dd02b96d8d0 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 13 Sep 2023 02:13:43 +0200 Subject: [PATCH] Always stringify collection requirement versions 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 #79109 Fixes #78067 --- lib/ansible/galaxy/dependency_resolution/dataclasses.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/galaxy/dependency_resolution/dataclasses.py b/lib/ansible/galaxy/dependency_resolution/dataclasses.py index 1ca98610b99..d1262efd4a3 100644 --- a/lib/ansible/galaxy/dependency_resolution/dataclasses.py +++ b/lib/ansible/galaxy/dependency_resolution/dataclasses.py @@ -310,6 +310,8 @@ class _ComputedReqKindsMixin: 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) req_type = collection_req.get('type') # TODO: decide how to deprecate the old src API behavior req_source = collection_req.get('source', None)