Skip to content

fix(runtime-import): handle repo-root-absolute paths with leading / or //#24903

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-runtime-import-resolver
Apr 6, 2026
Merged

fix(runtime-import): handle repo-root-absolute paths with leading / or //#24903
pelikhan merged 5 commits intomainfrom
copilot/fix-runtime-import-resolver

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

The runtime import resolver ignored leading slashes on paths like /.agents/skills/my-skill/instructions.md or //.github/agents/planner.md, falling through to the default branch and incorrectly resolving to .github/workflows/.agents/…. The compile-time resolver (ResolveIncludePath in remote_fetch.go) already handled this correctly; the runtime JS resolver was never updated to match.

Changes

  • actions/setup/js/runtime_import.cjs — strip all leading / characters (using replace(/^\/+/, "")) before prefix checks, but only when the remainder starts with .agents/ or .github/ (both separators). This handles single (/), double (//), or any number of leading slashes. Paths with unrecognised prefixes are left unchanged and safely fall through to the existing default branch (confined to .github/workflows/).

  • actions/setup/js/runtime_import.test.cjs — add regression tests for /.agents/…, //.agents/…, /.github/…, //.github/…, and a safety test confirming /etc/passwd never escapes to the system path.

// Before: /.agents/skills/my-skill/instructions.md  OR  //.agents/skills/my-skill/instructions.md
//   → .github/workflows/.agents/skills/my-skill/instructions.md  ❌

// After: strips all leading "/" → .agents/skills/my-skill/instructions.md
//   → <GITHUB_WORKSPACE>/.agents/skills/my-skill/instructions.md  ✅

Copilot AI and others added 2 commits April 6, 2026 14:52
Strip the leading "/" from paths like /.agents/skills/my-skill/instructions.md
and /.github/agents/planner.md before the existing prefix checks in
processRuntimeImport(). This mirrors the compile-time behavior in
ResolveIncludePath (remote_fetch.go) introduced in PR #24501.

Add regression tests for:
- /.agents/... paths resolving to workspace-root .agents folder
- /.github/... paths resolving within .github folder
- /etc/passwd (unrecognised prefix) safely falling through to .github/workflows/

Closes #24501

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8a3e3249-84d4-4655-a138-450674869af8

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix runtime import resolver for repo-root-absolute paths fix(runtime-import): handle repo-root-absolute paths with leading / Apr 6, 2026
Copilot AI requested a review from pelikhan April 6, 2026 14:54
Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot handle path starting with //

Replace single-slash strip with regex /^\/+/ so that paths beginning with
// (or any number of slashes) are also normalised before the .agents/ /
.github/ prefix checks. Add regression tests for //.agents/ and //.github/.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/26793fd8-125c-4d4e-a130-a9381c998dcf

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 6, 2026

@copilot handle path starting with //

Done in 0a48505. Changed filepath.substring(1) to filepath.replace(/^\/+/, "") so any number of leading slashes are stripped before the .agents/ / .github/ prefix checks. Added regression tests for //.agents/… and //.github/… paths.

Copilot AI changed the title fix(runtime-import): handle repo-root-absolute paths with leading / fix(runtime-import): handle repo-root-absolute paths with leading / or // Apr 6, 2026
Copilot AI requested a review from pelikhan April 6, 2026 15:02
@pelikhan pelikhan marked this pull request as ready for review April 6, 2026 16:07
Copilot AI review requested due to automatic review settings April 6, 2026 16:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the runtime import resolver’s path handling with the compile-time resolver by correctly supporting repo-root-absolute include paths that begin with one or more / characters (e.g., /.agents/..., //.github/...).

Changes:

  • Update processRuntimeImport to strip leading / characters only when the remaining path starts with .agents/ or .github/ (including \ variants).
  • Add regression tests for /.agents/..., //.agents/..., /.github/..., //.github/..., plus a safety-oriented test for /etc/passwd.
Show a summary per file
File Description
actions/setup/js/runtime_import.cjs Adds guarded leading-slash stripping to correctly resolve repo-root-absolute .agents/.github paths at runtime.
actions/setup/js/runtime_import.test.cjs Adds regression tests covering leading-slash variants for .agents/.github and a “non-allowed absolute path” case.

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: 1

Comment thread actions/setup/js/runtime_import.test.cjs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pelikhan pelikhan merged commit 99a05f7 into main Apr 6, 2026
50 checks passed
@pelikhan pelikhan deleted the copilot/fix-runtime-import-resolver branch April 6, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime import resolver does not handle repo-root-absolute paths (leading /)

3 participants