Skip to content

Commit ee9db51

Browse files
jcristauEijebong
andauthored
Fix error handling in verify_run_task_caches (#856)
* Fix error handling in verify_run_task_caches We were hiding the actual error by causing a TypeError. * Add tests for `verify_run_task_caches` --------- Co-authored-by: Bastien Orivel <borivel@mozilla.com>
1 parent 75b28dc commit ee9db51

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/taskgraph/util/verify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,14 @@ def verify_run_task_caches(task, taskgraph, scratch_pad, graph_config, parameter
351351

352352
if not run_task:
353353
raise Exception(
354-
f"{task['label']} is using a cache ({cache}) reserved for run-task "
354+
f"{task.label} is using a cache ({cache}) reserved for run-task "
355355
"change the task to use run-task or use a different "
356356
"cache name"
357357
)
358358

359359
if suffix not in cache:
360360
raise Exception(
361-
f"{task['label']} is using a cache ({cache}) reserved for run-task "
361+
f"{task.label} is using a cache ({cache}) reserved for run-task "
362362
"but the cache name is not dependent on the contents "
363363
"of run-task; change the cache name to conform to the "
364364
"naming requirements"

test/test_util_verify.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,43 @@ def make_task_treeherder(label, symbol, platform="linux/opt"):
265265
pytest.raises(Exception),
266266
id="dependencies over limit",
267267
),
268+
pytest.param(
269+
"verify_run_task_caches",
270+
make_graph(
271+
make_task("task1", task_def={"payload": {"cache": {"foo": {}}}})
272+
),
273+
pytest.raises(Exception, match="not appropriate for its trust-domain"),
274+
id="using cache with wrong trust-domain",
275+
),
276+
pytest.param(
277+
"verify_run_task_caches",
278+
make_graph(
279+
make_task(
280+
"task1",
281+
task_def={
282+
"payload": {"cache": {"test-domain-level-1-checkouts": {}}}
283+
},
284+
)
285+
),
286+
pytest.raises(Exception, match="reserved for run-task"),
287+
id="using reserved cache",
288+
),
289+
pytest.param(
290+
"verify_run_task_caches",
291+
make_graph(
292+
make_task(
293+
"task1",
294+
task_def={
295+
"payload": {
296+
"cache": {"test-domain-level-1-checkouts": {}},
297+
"command": ["run-task"],
298+
}
299+
},
300+
)
301+
),
302+
pytest.raises(Exception, match="cache name is not dep"),
303+
id="using run-task without cache suffix",
304+
),
268305
),
269306
)
270307
@pytest.mark.filterwarnings("error")

0 commit comments

Comments
 (0)