Skip to content

Commit 32de50b

Browse files
Eijebongahal
authored andcommitted
Update taskcluster to 91+ to fix get_artifact
This fixes a regression from 384afee where we started using the taskcluster python client instead of making requests manually. The artifacts route is special because the API returns some JSON as part of a 303 to the artifact's content URL. The previous code followed that 303. The python client before tascluster 91 does not. So instead we're getting the body which looks like this: `{"type": "s3/...", "url": "whereverthe303pointsat"}`. I also fixed the test as the previous one was basically ignoring the fact that taskcluster was returning a 303 and was mocking as if it didn't exist. Fixes #812
1 parent 90a12a6 commit 32de50b

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
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>=55.0",
32+
"taskcluster>=91.0",
3333
"taskcluster-urls>=11.0",
3434
"voluptuous>=0.12.1",
3535
]

test/test_util_taskcluster.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,41 @@ def test_get_artifact(responses, root_url):
110110

111111
# Test text artifact
112112
responses.get(
113-
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.txt",
113+
"http://foo.bar/artifact.txt",
114114
body=b"foobar",
115115
)
116+
responses.get(
117+
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.txt",
118+
body=b'{"type": "s3", "url": "http://foo.bar/artifact.txt"}',
119+
status=303,
120+
headers={"Location": "http://foo.bar/artifact.txt"},
121+
)
116122
raw = tc.get_artifact(tid, "artifact.txt")
117123
assert raw.read() == b"foobar"
118124

119125
# Test JSON artifact
126+
responses.get("http://foo.bar/artifact.json", json={"foo": "bar"})
120127
responses.get(
121128
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.json",
122-
json={"foo": "bar"},
129+
body=b'{"type": "s3", "url": "http://foo.bar/artifact.json"}',
130+
status=303,
131+
headers={"Location": "http://foo.bar/artifact.json"},
123132
)
124133
result = tc.get_artifact(tid, "artifact.json")
125134
assert result == {"foo": "bar"}
126135

127136
# Test YAML artifact
128137
expected_result = {"foo": b"\xe2\x81\x83".decode()}
129138
responses.get(
130-
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.yml",
139+
"http://foo.bar/artifact.yml",
131140
body=b'foo: "\xe2\x81\x83"',
132141
)
142+
responses.get(
143+
f"{root_url}/api/queue/v1/task/{tid}/artifacts/artifact.yml",
144+
body=b'{"type": "s3", "url": "http://foo.bar/artifact.yml"}',
145+
status=303,
146+
headers={"Location": "http://foo.bar/artifact.yml"},
147+
)
133148
result = tc.get_artifact(tid, "artifact.yml")
134149
assert result == expected_result
135150

uv.lock

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

0 commit comments

Comments
 (0)