Skip to content

Commit 00ac14e

Browse files
committed
Update taskcluster dependency
taskcluster v92 stopped following redirects, so do that ourselves in taskgraph.util.taskcluster's get_artifact and get_artifact_from_index functions.
1 parent 330e035 commit 00ac14e

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies = [
2929
"redo>=2.0",
3030
"requests>=2.25",
3131
"slugid>=2.0",
32-
"taskcluster>=91.0,<92.0",
32+
"taskcluster>=92.0",
3333
"taskcluster-urls>=11.0",
3434
"voluptuous>=0.12.1",
3535
]

src/taskgraph/util/taskcluster.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,9 @@ def get_taskcluster_client(service: str):
7171

7272

7373
def _handle_artifact(
74-
path: str, response: Union[requests.Response, dict[str, Any]]
74+
path: str,
75+
response: requests.Response,
7576
) -> Any:
76-
# When taskcluster client returns non-JSON responses, it wraps them in {"response": <Response>}
77-
if (
78-
isinstance(response, dict)
79-
and "response" in response
80-
and isinstance(response["response"], requests.Response)
81-
):
82-
response = response["response"]
83-
84-
if not isinstance(response, requests.Response):
85-
# At this point, if we don't have a response object, it's already parsed, return it
86-
return response
87-
88-
# We have a response object, load the content based on the path extension.
8977
if path.endswith(".json"):
9078
return response.json()
9179

@@ -159,6 +147,7 @@ def get_artifact(task_id, path):
159147
"""
160148
queue = get_taskcluster_client("queue")
161149
response = queue.getLatestArtifact(task_id, path)
150+
response = get_session().get(response["url"])
162151
return _handle_artifact(path, response)
163152

164153

@@ -231,6 +220,8 @@ def pagination_handler(response):
231220
def get_artifact_from_index(index_path, artifact_path):
232221
index = get_taskcluster_client("index")
233222
response = index.findArtifactFromTask(index_path, artifact_path)
223+
assert 300 <= response["response"].status_code <= 400
224+
response = get_session().get(response["response"].headers["location"])
234225
return _handle_artifact(artifact_path, response)
235226

236227

test/test_util_taskcluster.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ def test_get_artifact_from_index(responses, root_url):
237237

238238
responses.get(
239239
f"{root_url}/api/index/v1/task/{index}/artifacts/{path}",
240-
body=b"foobar",
240+
status=303,
241+
headers={"Location": f"http://foo.bar/{path}"},
241242
)
243+
responses.get(f"http://foo.bar/{path}", body="foobar")
242244

243245
result = tc.get_artifact_from_index(index, path)
244246
assert result.read() == b"foobar"
@@ -252,6 +254,11 @@ def test_get_artifact_from_index_uses_artifact_path_for_parsing(responses, root_
252254

253255
responses.get(
254256
f"{root_url}/api/index/v1/task/{index_path}/artifacts/{artifact_path}",
257+
status=303,
258+
headers={"Location": f"http://foo.bar/{artifact_path}"},
259+
)
260+
responses.get(
261+
f"http://foo.bar/{artifact_path}",
255262
body=b"key: value",
256263
)
257264

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)