GeezerVison is showing github.com — Persist CodeQL version output to file rather than environment by mario-campos · Pull Request #4081 · github/codeql-action
Conversation
mario-campos
commented
Aug 7, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Currently, the output of codeql version is cached and persisted between steps as an environment variable. This is fine, for now, but, as we begin to cache more of the CLI, we should persist that output to a file instead because:
- There is a limit to the size of a process' environment. On GitHub Actions, the runners already have a populated environment. And, the output of these CLI commands may be verbose.
- There is data to suggest that a larger environment has performance implications (more environment variables -> more memory for the kernel to copy during
execve(2)).
To that end, and as a precaution, this PR replaces $CODEQL_ACTION_CLI_VERSION_INFO with $CODEQL_ACTION_TEMP/version.json, a file-backed cache for codeql version.
Changes
- Moved the CodeQL CLI version caching logic from
util.ts (which used environment variables) into a new module src/cli/output-cache.ts, which now uses a temporary on-disk file (codeql-action-command-cache.json) for cross-step persistence. This includes new functions for caching, retrieving, and resetting the cached version, as well as improved validation of persisted data.
- Moved the
VersionInfo type definition from codeql.ts to a new shared file src/cli/types.ts, and updated all references to use the new location. This centralizes type definitions to avoid cyclic dependencies.
- Removed the now-obsolete
CODEQL_VERSION_INFO environment variable from EnvVar in environment.ts.
Risk assessment
For internal use only. Please select the risk level of this change:
- Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.
Which use cases does this change impact?
Workflow types:
- Advanced setup - Impacts users who have custom CodeQL workflows.
- Managed - Impacts users with
dynamic workflows (Default Setup, Code Quality, ...).
Products:
- Code Scanning - The changes impact analyses when
analysis-kinds: code-scanning.
- Code Quality - The changes impact analyses when
analysis-kinds: code-quality.
Environments:
- Dotcom - Impacts CodeQL workflows on
github.com and/or GitHub Enterprise Cloud with Data Residency.
- GHES - Impacts CodeQL workflows on GitHub Enterprise Server.
How did/will you validate this change?
- Unit tests - I am depending on unit test coverage (i.e. tests in
.test.ts files).
- End-to-end tests - I am depending on PR checks (i.e. tests in
pr-checks).
If something goes wrong after this change is released, what are the mitigation and rollback strategies?
- Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.
How will you know if something goes wrong after this change is released?
- Telemetry - I rely on existing telemetry or have made changes to the telemetry.
- Alerts - New or existing monitors will trip if something goes wrong with this change.
Are there any special considerations for merging or releasing this change?
- No special considerations - This change can be merged at any time.
Merge / deployment checklist
- Confirm this change is backwards compatible with existing workflows.
- Consider adding a changelog entry for this change.
- Confirm the readme and docs have been updated if necessary.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Moves persisted CodeQL CLI version metadata from an environment variable to a temporary JSON file.
Changes:
- Writes and reads version metadata from
$CODEQL_ACTION_TEMP/version.json.
- Removes the obsolete environment variable.
- Updates persistence tests.
Show a summary per file
| File |
Description |
src/util.ts |
Implements file-based version caching. |
src/util.test.ts |
Updates cache-reading tests. |
src/environment.ts |
Removes the old cache environment variable. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is particularly important for the first time that `getCachedCodeQlVersion` is invoked, as this cache file will not yet exist.
mbg
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this back up! I have added a few inline (mostly style) comments.
Some high-level points:
- Also added as an in-line comment, but do you plan to have a separate file for each command? If so, why? On the same topic, if not, then should the file be more structured to allow for relevant metadata and other command output down the line?
- Have you had any more thoughts about either checking that the cached file is intended for the current analysis (e.g. by checking the generated
jobUuid) or deleting cache files on "startup"?
- Add a unit test for the case where the file cannot be read (e.g. because it doesn't exist).
- The linter CI is failing. Remember to run
npm lint locally before committing / pushing changes.
Much more minor, but I spotted this in the PR description:
This is fine, for now, but, as we begin to cache more of the CLI, we should persist that output to a file instead.
The reasoning here ("as we begin to cache more of the CLI") doesn't really justify the conclusion ("we should persist that output to a file instead). Could you edit that to actually highlight why files are preferable to environment variables?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This brings them out of the crowded all-purpose `util.ts` and into `cli/output-cache.ts` where they are exclusively used.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This will ensure it works nicely with `JSON.stringify`. And, then we can validate the type before marshaling.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# lib/entry-points.js
mbg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, aside from addressing the minor point about the logging the error and resolving the merge conflict.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 14, 2026
This was referenced Aug 21, 2026
Reviewers
mbg
mbg approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|