releng/docker_assemble.py: fix empty auths error

I had a `~/.docker/config.json` which was missing an `auths` key, which
caused an error. The release automation succesfully ignored the error,
but it was noisy. Using `json_obj.get('auths', {})` instead of
`json_obj['auths']` fixes this `KeyError`.

Change-Id: I022583e9e668bf8ad7bdc1fa5a3305aee2f18d85
This commit is contained in:
Rebecca Turner
2025-05-13 12:18:32 -07:00
parent 2e25580d8d
commit 4611d1f331
+2 -1
View File
@@ -248,7 +248,8 @@ class AuthState:
with path.open() as fh:
try:
json_obj = json.load(fh)
return {k: v['auth'] for k, v in json_obj['auths'].items()}
auths = json_obj.get('auths', {})
return {k: v['auth'] for k, v in auths.items()}
except (json.JSONDecodeError, KeyError) as e:
log.exception('JSON decode error in %s', path, exc_info=e)
return {}