diff --git a/atomic_reactor/utils/cachi2.py b/atomic_reactor/utils/cachi2.py index d9e1ee444..0191f3599 100644 --- a/atomic_reactor/utils/cachi2.py +++ b/atomic_reactor/utils/cachi2.py @@ -40,7 +40,12 @@ def remote_source_to_cachi2(remote_source: Dict[str, Any]) -> Dict[str, Any]: ) cachi2_packages = [] - for pkg_manager in remote_source["pkg_managers"]: + pkg_managers = remote_source.get("pkg_managers") + if pkg_managers is None: + # Cachito behavior, missing pkg_managers means to use gomod + pkg_managers = ["gomod"] + + for pkg_manager in pkg_managers: if pkg_manager in removed_pkg_managers: continue diff --git a/tests/utils/test_cachi2.py b/tests/utils/test_cachi2.py index 25e0e99d6..b8db18f30 100644 --- a/tests/utils/test_cachi2.py +++ b/tests/utils/test_cachi2.py @@ -27,6 +27,11 @@ {"flags": [], "packages": [{"path": ".", "type": "bundler"}]}, id="pkg_rubygems_to_bundler", ), + pytest.param( + {}, + {"flags": [], "packages": [{"path": ".", "type": "gomod"}]}, + id="pkg_manager_missing", + ), pytest.param( {"pkg_managers": ["gomod"], "packages": {"gomod": [{"path": "operator"}]}}, {"flags": [], "packages": [{"path": "operator", "type": "gomod"}]},