Skip to content

Commit 7c3c025

Browse files
committed
Use TrustedMetadataSet.root property consistently
In order to consistently use the 'root' property internally, just try/except the KeyError during the loading of initial trusted root when 'root' key does not exist yet. Signed-off-by: Teodora Sechkova <[email protected]>
1 parent d9b0956 commit 7c3c025

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tuf/ngclient/_internal/trusted_metadata_set.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,16 @@ def update_root(self, data: bytes) -> None:
169169
f"Expected 'root', got '{new_root.signed.type}'"
170170
)
171171

172-
if self._trusted_set.get("root") is not None:
172+
try:
173173
# We are not loading initial trusted root: verify the new one
174174
self.root.verify_delegate("root", new_root)
175175

176176
if new_root.signed.version != self.root.signed.version + 1:
177177
raise exceptions.ReplayedMetadataError(
178178
"root", new_root.signed.version, self.root.signed.version
179179
)
180+
except KeyError:
181+
logger.debug("Loading initial trusted root")
180182

181183
new_root.verify_delegate("root", new_root)
182184

0 commit comments

Comments
 (0)