From 4611d1f33193a56516c128b070c9671d78ce15a6 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Tue, 13 May 2025 11:55:12 -0700 Subject: [PATCH] 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 --- releng/docker_assemble.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/releng/docker_assemble.py b/releng/docker_assemble.py index d5b47c328..21754336b 100644 --- a/releng/docker_assemble.py +++ b/releng/docker_assemble.py @@ -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 {}