diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index 5cae18bf10bd..deb877fafb43 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -511,10 +511,10 @@ def resolve(key): if not parent: # base case: nothing else needs resolving return path parent_path = resolve(parent) # recursively resolve parent path - if path is not None: + if path: path = os.path.join(parent_path, path) # resolve path else: - path = parent_path # or use parent path + log.warning("Trying to resolve path for the '%s' option but it's empty/None", key) setattr(self, key, path) # update property _cache[key] = path # cache it! @@ -557,6 +557,8 @@ def get_path(current_path, initial_path): return current_path current_value = getattr(self, key) # resolved path or list of resolved paths + if not current_value: + return if isinstance(current_value, list): initial_paths = listify(self._raw_config[key], do_strip=True) # initial unresolved paths updated_paths = [] diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 3e9a306e4116..f55562de63b0 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -384,6 +384,8 @@ def __init__(self, app: MinimalManagerApp): f" release of Galaxy. Please convert to YAML at {self.app.config.job_config_file} or" f" explicitly set `job_config_file` to {job_config_file} to remove this message" ) + if not job_config_file: + raise OSError() if ".xml" in job_config_file: tree = load(job_config_file) job_config_dict = self.__parse_job_conf_xml(tree) diff --git a/test/unit/config/test_path_graph.py b/test/unit/config/test_path_graph.py index 02f33787081f..77afe7333c55 100644 --- a/test/unit/config/test_path_graph.py +++ b/test/unit/config/test_path_graph.py @@ -142,7 +142,7 @@ def test_resolves_to_invalid_type(monkeypatch): def test_resolves_with_empty_component(monkeypatch): - # A path can be None (root path is never None; may be asigned elsewhere) + # A path can be None (root path is never None; may be assigned elsewhere) mock_schema = { "path0": { "type": "str", @@ -155,7 +155,7 @@ def test_resolves_with_empty_component(monkeypatch): "path2": { "type": "str", "default": "value2", - "path_resolves_to": "path1", + "path_resolves_to": "path0", }, } monkeypatch.setattr(AppSchema, "_read_schema", lambda a, b: get_schema(mock_schema)) @@ -163,5 +163,5 @@ def test_resolves_with_empty_component(monkeypatch): config = BaseAppConfiguration() assert config.path0 == "value0" - assert config.path1 == "value0" + assert config.path1 is None assert config.path2 == "value0/value2" diff --git a/test/unit/config/test_path_resolves_to.py b/test/unit/config/test_path_resolves_to.py index 97953b3d0787..d7e7dd0918d6 100644 --- a/test/unit/config/test_path_resolves_to.py +++ b/test/unit/config/test_path_resolves_to.py @@ -132,21 +132,21 @@ def test_kwargs_relative_path_old_prefix_for_other_option(mock_init): def test_kwargs_relative_path_old_prefix_empty_after_strip(mock_init): # Expect: use value from kwargs, strip old prefix, then resolve - new_path1 = "old-config" + new_path1 = "old-config/foo" config = BaseAppConfiguration(path1=new_path1) - assert config.path1 == "my-config/" # stripped of old prefix, then resolved + assert config.path1 == "my-config/foo" # stripped of old prefix, then resolved assert config.path2 == "my-data/my-data-files" # stripped of old prefix, then resolved assert config.path3 == "my-other-files" # no change def test_kwargs_set_to_null(mock_init): - # Expected: allow overriding with null, then resolve + # Expected: allow overriding with null # This is not a common scenario, but it does happen: one example is # `job_config` set to `None` when testing config = BaseAppConfiguration(path1=None) - assert config.path1 == "my-config" # resolved + assert config.path1 is None assert config.path2 == "my-data/my-data-files" # resolved assert config.path3 == "my-other-files" # no change