diff --git a/src/taskgraph/util/taskcluster.py b/src/taskgraph/util/taskcluster.py index 46cd2a598..b8cf8d562 100644 --- a/src/taskgraph/util/taskcluster.py +++ b/src/taskgraph/util/taskcluster.py @@ -231,7 +231,7 @@ def pagination_handler(response): def get_artifact_from_index(index_path, artifact_path): index = get_taskcluster_client("index") response = index.findArtifactFromTask(index_path, artifact_path) - return _handle_artifact(index_path, response) + return _handle_artifact(artifact_path, response) def list_tasks(index_path): diff --git a/test/test_util_taskcluster.py b/test/test_util_taskcluster.py index d6e97aaa2..887525857 100644 --- a/test/test_util_taskcluster.py +++ b/test/test_util_taskcluster.py @@ -243,6 +243,21 @@ def test_get_artifact_from_index(responses, root_url): assert result.read() == b"foobar" +def test_get_artifact_from_index_uses_artifact_path_for_parsing(responses, root_url): + # Verify artifact_path (not index_path) is used for determining how to parse the response. + index_path = "foo.bar" + artifact_path = "file.yml" + tc.get_taskcluster_client.cache_clear() + + responses.get( + f"{root_url}/api/index/v1/task/{index_path}/artifacts/{artifact_path}", + body=b"key: value", + ) + + result = tc.get_artifact_from_index(index_path, artifact_path) + assert result == {"key": "value"} + + def test_list_tasks(responses, root_url): index = "foo" tc.get_taskcluster_client.cache_clear()