What changed, and why it matters
This commit only changes a test file that checks how the software reports its version number when running inside GitHub Actions. It does not change the actual version-detection code or any security-sensitive behavior. There is no security issue here.
No security action needed. Treat as a normal test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies tests/test_version.py to explicitly set GITHUB_REF_NAME and GITHUB_SHA environment variables to empty strings in several test cases, rather than leaving them unset. It also updates assertions to match the new test setup. The change is a test-suite bugfix for CI behavior and does not touch production code, cryptographic operations, network handling, or user data.
Changed components
tests/test_version.pyInspect captured patch +14 / −4
diff --git a/tests/test_version.py b/tests/test_version.py
index aae1494..e2bc149 100644
--- a/tests/test_version.py
+++ b/tests/test_version.py
@@ -300,6 +300,7 @@ class TestVersionUtils_GithubActions(VersionBaseTest):
# TODO: I don't think this scenario ever happens.
with mock.patch.dict(os.environ, {
VersionUtils.ENV_VAR__GITHUB_ACTIONS__IS_CI: "true",
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__REF_NAME: "",
VersionUtils.ENV_VAR__GITHUB_ACTIONS__SHA: TEST__FULL_COMMIT_HASH,
}):
assert VersionUtils.get_version_name() == TEST__SHORT_COMMIT_HASH
@@ -310,6 +311,8 @@ class TestVersionUtils_GithubActions(VersionBaseTest):
# 100% test coverage.
with mock.patch.dict(os.environ, {
VersionUtils.ENV_VAR__GITHUB_ACTIONS__IS_CI: "true",
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__REF_NAME: "",
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__SHA: "",
}):
with pytest.raises(Exception):
VersionUtils.get_version_name()
@@ -339,16 +342,23 @@ class TestVersionUtils_GithubActions(VersionBaseTest):
env vars when set.
"""
# Need to signal that we're in a GitHub Actions CI environment
- with mock.patch.dict(os.environ, {VersionUtils.ENV_VAR__GITHUB_ACTIONS__IS_CI: "true"}):
- assert os.environ.get(VersionUtils.ENV_VAR__GITHUB_ACTIONS__REF_NAME) is None
- assert os.environ.get(VersionUtils.ENV_VAR__GITHUB_ACTIONS__SHA) is None
+ with mock.patch.dict(os.environ, {
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__IS_CI: "true",
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__REF_NAME: "",
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__SHA: "",
+ }):
assert VersionUtils._get_version_name_from_github_actions_env_vars() is None
+ # REF_NAME should be passed straight through
with mock.patch.dict(os.environ, {VersionUtils.ENV_VAR__GITHUB_ACTIONS__REF_NAME: TEST__VERSION_NAME}):
result = VersionUtils._get_version_name_from_github_actions_env_vars()
assert result == TEST__VERSION_NAME
- with mock.patch.dict(os.environ, {VersionUtils.ENV_VAR__GITHUB_ACTIONS__SHA: TEST__FULL_COMMIT_HASH}):
+ # Unlikely scenario: no REF_NAME but SHA is set; should return short commit hash
+ with mock.patch.dict(os.environ, {
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__REF_NAME: "",
+ VersionUtils.ENV_VAR__GITHUB_ACTIONS__SHA: TEST__FULL_COMMIT_HASH,
+ }):
result = VersionUtils._get_version_name_from_github_actions_env_vars()
assert result == TEST__SHORT_COMMIT_HASH[:7]
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.