fix(safe-outputs): trust cross-repo checkout dirs from manifest (dubious ownership)#40080
Merged
Conversation
configure_git_credentials.sh now reads the checkout manifest and adds each cross-repository checkout subdirectory as a git safe.directory. Without this, safe-outputs handlers that run git inside those subdirectories (resolved via repoCwd) fail with "dubious ownership", surfacing as "Failed to pin branch". Fixes #40079
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses safe-outputs failures when workflows perform cross-repository checkouts into workspace subdirectories by expanding git safe.directory configuration to include checkout subdirectories recorded in the checkout manifest, preventing “dubious ownership” errors during local git operations.
Changes:
- Extend
actions/setup/sh/configure_git_credentials.shto parse the checkout manifest (optionally overridden viaGH_AW_CHECKOUT_MANIFEST) and add each in-workspace checkout subdirectory togit config --global safe.directory. - Add Vitest coverage for manifest-based safe.directory behavior, including path traversal rejection and override support.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/sh/configure_git_credentials.sh | Adds manifest-driven safe.directory entries for cross-repo checkout subdirectories to avoid dubious ownership failures in safe-outputs handlers. |
| actions/setup/js/configure_git_credentials.test.cjs | Adds unit tests validating safe.directory additions, traversal rejection, override behavior, and no-manifest behavior. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
Contributor
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment.
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The autofix suggestion that added \r\n\0 path guards accidentally removed the for-loop's closing brace, breaking the embedded node script so it threw and trusted no cross-repo directories. This caused the configure_git_credentials JS tests to fail in CI.
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.
Summary
Fixes #40079.
Safe-outputs
create_pull_request(and other git-running handlers) fail withFailed to pin branch '<branch>'when a workflow uses a cross-repository checkout into a subdirectory (e.g.${GITHUB_WORKSPACE}/github). The branch exists locally, but git aborts thegit rev-parsepinning command with "dubious ownership" because the subdirectory is a separate git repository that was never trusted as asafe.directory.Root cause
actions/setup/sh/configure_git_credentials.shonly addedGITHUB_WORKSPACEas a gitsafe.directory. The safe-outputs MCP server resolves cross-repo checkouts to subdirectories (repoCwd, from the checkout manifest) and runs git there — those directories were untrusted.Fix
configure_git_credentials.shnow consults the checkout manifest ($RUNNER_TEMP/gh-aw/safeoutputs/checkout-manifest.json, orGH_AW_CHECKOUT_MANIFEST) and adds each recorded cross-repo checkout subdirectory (${GITHUB_WORKSPACE}/<path>) as asafe.directory, alongside the workspace itself.node(already present in both the agent job and the gh-aw-node container) to parse the JSON manifest.RUNNER_TEMP, ornodeare absent.Tests
Added
actions/setup/js/configure_git_credentials.test.cjscovering:GH_AW_CHECKOUT_MANIFESToverride honored