GeezerVison is showing github.com — Fix path-resolution bug in `changenotes.mts validate` by using `getChangenotes` by mario-campos · Pull Request #4156 · github/codeql-action
Conversation
isValidChangenoteFile receives a file name (no leading path) and then attempts to read that file, regardless of the CWD. If the user's CWD is not in unreleased-change-notes, then the command will likely fail to open the file.
Incidentally, for #4155, I've added getChangenotes, which consolidates some duplicative code between the assemble and validate commands. We can take advantage of that here in validate, and in so doing, fix the bug.
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:
Products:
Environments:
- Testing/None - This change does not impact any CodeQL workflows in production.
How did/will you validate this change?
- Unit tests - I am depending on unit test coverage (i.e. tests in
.test.ts files).
If something goes wrong after this change is released, what are the mitigation and rollback strategies?
- Development/testing only - This change cannot cause any failures in production.
How will you know if something goes wrong after this change is released?
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.
mario-campos
changed the title
Fix path-resolution bug in changenotes.mts validate command
Fix path-resolution bug in changenotes.mts validate by using getChangenotes
Sep 18, 2026
Uh oh!
There was an error while loading. Please reload this page.
This reduces duplicate code between `assemble` and `validate`. It also has the benefit of fixing a bug in the current implementation of `validate`, where `isValidChangenoteFile` receives a relative file name where it should receive an absolute one.
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.
Copilot review overview
🟢 Approval recommended
The focused change correctly fixes working-directory-dependent path resolution without leaving unresolved usages.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes changenote validation from arbitrary working directories by validating repository-rooted paths.
Changes:
- Uses
getChangenotes() to resolve changenote paths.
- Removes the obsolete aggregate validator and its tests.
| File |
Description |
pr-checks/changenotes.mts |
Validates changenotes using resolved paths. |
pr-checks/changelog/validate.mts |
Removes the unused aggregate validator. |
pr-checks/changelog/validate.test.mts |
Removes tests for the deleted helper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
The changes look good, but one question about the approach you took.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+119
to
+122
|
|
const allChangenotesValid = getChangenotes().reduce(
|
|
|
(r, changenote) => r && isValidChangenoteFile(changenote.absolutePath),
|
|
|
true,
|
|
|
);
|
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.
Rather than replacing the call to isValidAllChangenoteFiles with this inline implementation that uses getChangenotes(), do you think it would be better to update the existing implementation of isValidAllChangenoteFiles to accept ChangenoteFile[] and pass it the result of getChangenotes() here? That way you could keep (most of) the unit tests. You would need to move the definition of ChangenoteFile somewhere that is accessible to both files.
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.
I deleted isValidAllChangenoteFiles because the filter became redundant, which just left it to perform reduce. At that point, I think the function became a thin wrapper, which doesn't add much value (IMO). The deleted tests themselves were also redundant because they tested the same conditions but at a different level of abstraction. It seemed "cleaner" to inline it and shorten the test suite, but I'm indifferent about it. If you have a strong preference for keeping it, I won't mind.
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.
I am happy to merge this as-is for now. It's an easy enough change to make down the line if needed.
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 Sep 24, 2026
Reviewers
mbg
mbg approved these changes
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size/S
Should be easy to review
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.
|