environments: fail gracefully on missing keys (#26378)

This commit is contained in:
Seth R. Johnson 2022-05-24 17:52:40 +02:00 committed by GitHub
parent ba701a7cf8
commit 6a57aede57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1619,7 +1619,14 @@ def all_specs(self):
"""Return all specs, even those a user spec would shadow."""
all_specs = set()
for h in self.concretized_order:
all_specs.update(self.specs_by_hash[h].traverse())
try:
spec = self.specs_by_hash[h]
except KeyError:
tty.warn(
'Environment %s appears to be corrupt: missing spec '
'"%s"' % (self.name, h))
continue
all_specs.update(spec.traverse())
return sorted(all_specs)