diff --git a/src/taskgraph/util/verify.py b/src/taskgraph/util/verify.py index e4b9a530d..d7d60bacd 100644 --- a/src/taskgraph/util/verify.py +++ b/src/taskgraph/util/verify.py @@ -224,6 +224,25 @@ def verify_routes_notification_filters( ) +@verifications.add("full_task_graph") +def verify_index_route(task, taskgraph, scratch_pad, graph_config, parameters): + """ + This function ensures that routes do not contain forward slashes. + """ + if task is None: + return + task_dict = task.task + routes = task_dict.get("routes", []) + route_prefix = "index." + + for route in routes: + # Check for invalid / in the index route + if route.startswith(route_prefix) and "/" in route: + raise Exception( + f"{task.label} has invalid route with forward slash: {route}" + ) + + @verifications.add("full_task_graph") def verify_dependency_tiers(task, taskgraph, scratch_pad, graph_config, parameters): tiers = scratch_pad diff --git a/test/test_util_verify.py b/test/test_util_verify.py index 682179505..83cca3899 100644 --- a/test/test_util_verify.py +++ b/test/test_util_verify.py @@ -199,6 +199,21 @@ def make_task_treeherder(label, symbol, platform="linux/opt"): DeprecationWarning, id="routes_notfication_filter: deprecated", ), + pytest.param( + "verify_index_route", + make_graph( + make_task( + "invalid_slash", + task_def={ + "routes": [ + "index.example.com/foobar.v2.latest.taskgraph.decision" + ] + }, + ), + ), + Exception, + id="verify_index_route: invalid slash in route", + ), ), ) @pytest.mark.filterwarnings("error")