ci: Use os.environ[key] access when value must be set
What changed, and why it matters
This is a tiny internal cleanup in Bitcoin Core's continuous integration (CI) test runner script. It changes how two environment variables are read so the script crashes with a clear error if they are missing, rather than silently using a None value. The commit message says the variables are always set, so this is described as a no-behavior-change refactor. It is not a security fix and does not affect the Bitcoin network, wallets, or node software.
No security action needed. Treat as a normal code-quality/refactor commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In ci/test/02_run_container.py, the patch replaces os.getenv(‘USER’) and os.getenv(‘CONTAINER_NAME’) with os.environ[‘USER’] and os.environ[‘CONTAINER_NAME’]. The difference is that os.getenv returns None when a variable is absent, while os.environ[key] raises KeyError. The author states the variables are always set, so behavior is unchanged except for a clearer failure mode if they are ever missing. This is a defensive refactor in CI tooling, not a vulnerability patch.
Changed components
ci/test/02_run_container.pyInspect captured patch +2 / −2
diff --git a/ci/test/02_run_container.py b/ci/test/02_run_container.py
index c1c6b940..166acad7 100755
--- a/ci/test/02_run_container.py
+++ b/ci/test/02_run_container.py
@@ -36,8 +36,8 @@ def main():
# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
# to allow support starting multiple runs simultaneously by the same user.
env_file = "/tmp/env-{u}-{c}".format(
- u=os.getenv("USER"),
- c=os.getenv("CONTAINER_NAME"),
+ u=os.environ["USER"],
+ c=os.environ["CONTAINER_NAME"],
)
with open(env_file, "w", encoding="utf8") as file:
for k, v in os.environ.items():
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.