Bug 1390983 - Keyed-by default shouldn't be the only item, error out if it is. r=dustin
MozReview-Commit-ID: 6AKU4iakl3s
--- a/taskcluster/taskgraph/util/schema.py
+++ b/taskcluster/taskgraph/util/schema.py
@@ -110,16 +110,24 @@ def resolve_keyed_by(item, field, item_n
while True:
if not isinstance(value, dict) or len(value) != 1 or not value.keys()[0].startswith('by-'):
return item
keyed_by = value.keys()[0][3:] # strip off 'by-' prefix
key = extra_values.get(keyed_by) if keyed_by in extra_values else item[keyed_by]
alternatives = value.values()[0]
+ if len(alternatives) == 1 and 'default' in alternatives:
+ # Error out when only 'default' is specified as only alternatives,
+ # because we don't need to by-{keyed_by} there.
+ raise Exception(
+ "Keyed-by '{}' unnecessary with only value 'default' "
+ "found, when determining item '{}' in '{}'".format(
+ keyed_by, field, item_name))
+
matches = keymatch(alternatives, key)
if len(matches) > 1:
raise Exception(
"Multiple matching values for {} {!r} found while "
"determining item {} in {}".format(
keyed_by, key, field, item_name))
elif matches:
value = container[subfield] = matches[0]