Repository navigation
Record the parent commit on the Mayhem run - #259
Merged
Merged
Conversation
The run's parent_revision was never set. mcode-action now passes --parent-revision: an explicit parent-revision input, else the first parent of the recorded revision, read from its commit object so it works in a depth-1 checkout where `git rev-parse <rev>^` fails. Nothing is sent when that commit is not checked out (a pull request head) or is a root commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mayhem Automated Code Testing Report❗ 1 Defects Found
Testing details found at https://app.mayhem.security/forallsecure/mcode-action/mayhemit/71 |
ivg
reviewed
Oct 19, 2026
| try { | ||
| const out = execFileSync("git", ["cat-file", "commit", revision], { | ||
| cwd, | ||
| stdio: ["ignore", "pipe", "pipe"], |
Member
There was a problem hiding this comment.
you can pass encoding: "utf8" and drop toString, faster and more readable.
sauliusbc
reviewed
Oct 19, 2026
sauliusbc
left a comment
Contributor
There was a problem hiding this comment.
PR description is way too verbose for my taste, but lgtm otherwise.
ethan42
approved these changes
Oct 19, 2026
* Record the upstream commit as the Mayhem run's build id For a fork, mcode-action now passes --build-id: the newest commit the recorded revision shares with the upstream default branch, from the GitHub compare API. A build-id input overrides it; nothing is sent for a repository that is not a fork. * Ensure note for behavior change is visible.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Mayhem runs have a
parent_revisionfield, and run creation accepts it (RunPost.parent_revisiononPOST /api/v2/owner/{owner}/project/{project}/target/{target}/run). mcode-action never sends it, so runs started from GitHub Actions have it empty. It can't be filled in afterwards:PUT …/run/{n}(PutRun) only takesapi_run,created_atandupdated_at.With the parent recorded, a run can be tied to the commit it builds on without looking the revision up on the Git host, which fails once that commit is no longer reachable there.
Change
src/revision.ts:firstParent()reads the firstparentheader fromgit cat-file commit <revision>.git rev-parse <revision>^fails: the parent object wasn't fetched, but the commit still names it.parent …line in a commit message never matches.resolveParentRevision()picks, in order: an explicitparent-revisioninput, then that first parent, then none.src/main.ts: passes--parent-revision <sha>tomayhem runwhen there is one, and logs where it came from (Parent revision: <sha> (from commit object).). When there's no parent it passes nothing, so the run is created exactly as before. That covers a pull request head that isn't in the checkout, and a root commit.action.ymlandREADME.md: document the new optionalparent-revisioninput.dist/: rebuilt withnccfrom the locked dependencies (yarn install --frozen-lockfile).--parent-revision(alias--scm-parent-revision) is listed inmayhem run --helpfor CLI 2.14.14, the version the action downloads today.Testing
yarn run all(build, format, lint, package, jest): clean, 23/23.__tests__/revision.test.ts:HEAD^fails but the parent is still read;parentline;Parent revision: 8dbc665… (from commit object), which is the parent of the PR head66ad837, and passes--parent-revision 8dbc665…tomayhem run. The debug job shows the runPOSTreturning 200. Runs created:forallsecure/mcode-action/lighttpd212–214,forallsecure/mcode-action/mayhemit69 andmcode-action/mcode-action/lighttpd72.Rollout
Workflows on
ForAllSecure/mcode-action@v1pick this up on their next run once it ships in v1.0.x and thev1tag moves. Workflows that pin a commit need a bump. Runs created before the release keep an emptyparent_revision.🤖 Generated with Claude Code