Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c5585e

Browse filesBrowse files
authored
Merge pull request #3852 from github/henrymercer/avoid-diagnostic-collisions
Add random suffix when writing diagnostics to avoid filename collisions
2 parents 19b3a84 + 245f682 commit 7c5585e
Copy full SHA for 7c5585e

8 files changed

+60-15Lines changed: 60 additions & 15 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
44

55
## [UNRELEASED]
66

7-
No user facing changes.
7+
- Fixed a bug where two diagnostics produced within the same millisecond could overwrite each other on disk, causing one of them to be lost. [#3852](https://github.com/github/codeql-action/pull/3852)
88

99
## 4.35.2 - 15 Apr 2026
1010

Collapse file

‎lib/analyze-action.js‎

Copy file name to clipboardExpand all lines: lib/analyze-action.js
+7-2Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/init-action-post.js‎

Copy file name to clipboardExpand all lines: lib/init-action-post.js
+7-2Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/init-action.js‎

Copy file name to clipboardExpand all lines: lib/init-action.js
+7-2Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/setup-codeql-action.js‎

Copy file name to clipboardExpand all lines: lib/setup-codeql-action.js
+7-2Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/upload-lib.js‎

Copy file name to clipboardExpand all lines: lib/upload-lib.js
+7-2Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/upload-sarif-action.js‎

Copy file name to clipboardExpand all lines: lib/upload-sarif-action.js
+7-2Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎src/diagnostics.ts‎

Copy file name to clipboardExpand all lines: src/diagnostics.ts
+17-2Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ let unwrittenDiagnostics: UnwrittenDiagnostic[] = [];
7272
*/
7373
let unwrittenDefaultLanguageDiagnostics: DiagnosticMessage[] = [];
7474

75+
/**
76+
* Counter used to generate a unique suffix for each diagnostic filename, so that
77+
* two diagnostics produced within the same millisecond do not overwrite each
78+
* other on disk.
79+
*/
80+
let diagnosticCounter = 0;
81+
7582
/**
7683
* Constructs a new diagnostic message with the specified id and name, as well as optional additional data.
7784
*
@@ -167,10 +174,18 @@ function writeDiagnostic(
167174
// Create the directory if it doesn't exist yet.
168175
mkdirSync(diagnosticsPath, { recursive: true });
169176

177+
// Include a monotonically increasing suffix to avoid filename collisions
178+
// between diagnostics produced within the same millisecond.
179+
const uniqueSuffix = (diagnosticCounter++).toString();
180+
// We should only need to remove colons, but to be defensive, only allow a restricted set of
181+
// characters.
182+
const sanitizedTimestamp = diagnostic.timestamp.replace(
183+
/[^a-zA-Z0-9.-]/g,
184+
"",
185+
);
170186
const jsonPath = path.resolve(
171187
diagnosticsPath,
172-
// Remove colons from the timestamp as these are not allowed in Windows filenames.
173-
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`,
188+
`codeql-action-${sanitizedTimestamp}-${uniqueSuffix}.json`,
174189
);
175190

176191
writeFileSync(jsonPath, JSON.stringify(diagnostic));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.