Skip to content

Fix runtime-import path extraction for .github.io repositories#15826

Merged
pelikhan merged 4 commits intomainfrom
copilot/fix-runtime-import-path
Feb 15, 2026
Merged

Fix runtime-import path extraction for .github.io repositories#15826
pelikhan merged 4 commits intomainfrom
copilot/fix-runtime-import-path

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

Plan: Fix runtime-import path generation for .github.io repos

Issue Analysis

When compiling workflows in repositories ending with .github.io (e.g., username.github.io), the runtime-import path incorrectly includes .github.io prefix.

Root Cause: Line 325 of pkg/workflow/compiler_yaml.go uses strings.Index(c.markdownPath, ".github") which matches .github.io in the repo path before matching the actual .github/workflows directory.

Example:

  • Repo: /home/user/username.github.io/.github/workflows/test.md
  • Current behavior: Matches .github at position after username, extracts .github.io/.github/workflows/test.md
  • Expected behavior: Should match .github at the directory level, extract .github/workflows/test.md

Implementation Plan

  • Investigate and understand the issue
  • Write unit test to reproduce the bug
  • Fix the path extraction logic to match /.github/ directory instead of substring
  • Run unit tests to verify fix
  • Run make agent-finish (fmt, lint, tests all pass)
  • Verify manual testing
  • Recompile all workflows (no changes needed)
  • Anonymize usernames in test cases

Changes Made

  1. Test Added (pkg/workflow/compiler_yaml_test.go):

    • TestRuntimeImportPathGitHubIO: Tests 4 scenarios including .github.io repos
    • Verifies correct path generation without duplication
    • Tests both GitHub Pages repos and normal repos
    • Uses anonymized usernames (testuser, anotheruser)
  2. Fix Applied (pkg/workflow/compiler_yaml.go):

    • Changed from strings.Index(c.markdownPath, ".github") to strings.Index(normalizedPath, "/.github/")
    • Normalize path separators first for cross-platform compatibility
    • Match directory component, not arbitrary substrings in repo names
    • Extract path from .github/ onwards (without leading slash)

Testing Results

✅ All unit tests pass
✅ Linting passes
✅ Formatting passes
✅ Manual testing confirms fix:

  • testuser.github.io{{#runtime-import .github/workflows/translate-to-ptbr.md}}
  • Normal repos → {{#runtime-import .github/workflows/test.md}}
  • No .github.io/.github/workflows/ duplication ✓
Original prompt

This section details on the original issue you should resolve

<issue_title>gh aw compile generates incorrect runtime-import path for repos ending in .github.io</issue_title>
<issue_description>## Bug Description

When running gh aw compile in a repository whose name ends with .github.io (e.g., username.github.io), the compiled lock file contains an incorrect runtime-import path.

Expected Behavior

The compiled .lock.yml file should contain:

{{#runtime-import .github/workflows/translate-to-ptbr.md}}

Actual Behavior

The compiled .lock.yml file contains:

{{#runtime-import .github.io/.github/workflows/translate-to-ptbr.md}}

The .github.io suffix from the repository name (samueltauil.github.io) is incorrectly prepended to the import path, resulting in:

workflows/.github.io/.github/workflows/translate-to-ptbr.md

This causes the workflow to fail at runtime with:

Failed to process runtime import for .github.io/.github/workflows/translate-to-ptbr.md: Runtime import file not found: workflows/.github.io/.github/workflows/translate-to-ptbr.md

Steps to Reproduce

  1. Create a repository named <username>.github.io (a GitHub Pages repo)
  2. Create an agentic workflow markdown file at .github/workflows/translate-to-ptbr.md
  3. Run gh aw compile
  4. Inspect the generated .github/workflows/translate-to-ptbr.lock.yml
  5. Observe the runtime-import directive has an incorrect path with .github.io/ prefix

Root Cause

It appears the compiler is parsing the repository name and incorrectly extracting a path component from the .github.io suffix in the repo name, then prepending it to the workflow file's import path.

Workaround

Manually edit the compiled .lock.yml file to correct the path from .github.io/.github/workflows/... to .github/workflows/.... Note: this fix will be overwritten on the next gh aw compile.

Environment

  • gh-aw version: v0.44.0
  • Repository: samueltauil/samueltauil.github.io
  • OS: Windows 11
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.



✨ PR Review Safe Output Test - Run 22027664548

💥 [THE END] — Illustrated by Smoke Claude

- Add test cases for repositories ending with .github.io
- Fix path extraction to match /.github/ directory instead of substring
- Normalize path separators before searching for .github directory
- Prevents incorrect paths like .github.io/.github/workflows/file.md

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect runtime-import path for .github.io repos Fix runtime-import path extraction for .github.io repositories Feb 15, 2026
Copilot AI requested a review from pelikhan February 15, 2026 01:52
@pelikhan
Copy link
Contributor

@copilot recompile

Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot recompile

Recompiled all 154 workflows successfully. No lock file changes were needed since the fix only affects repositories with .github.io in their path (like username.github.io). The current repository gh-aw is not affected.

The fix has been tested and verified to:

  • ✅ Correctly extract .github/workflows/ path for .github.io repos
  • ✅ Work correctly for normal repos (unchanged behavior)
  • ✅ All workflows compile without errors

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v2 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/11bd71901bbe5b1630ceea73d27597364c9af683
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/11bd71901bbe5b1630ceea73d27597364c9af683 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha developer-action-main/dist/index.js (http block)
  • https://api.github.com/repos/actions/download-artifact/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/download-artifact/git/ref/tags/v6 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v7
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v7 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/4dc6199c7b1a012772edbd06daecab0f50c9053c
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/4dc6199c7b1a012772edbd06daecab0f50c9053c --jq .object.sha (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v5 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v6 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq .object.sha (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v6 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v6 --jq .object.sha data/action_pins.json...&#34; (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v6 --jq .object.sha js is not installed.&#34;; \ echo &#34;&#34;; \ echo &#34;This project requires Node.js 20 or higher.&#34;; \ echbash (http block)
  • https://api.github.com/repos/anchore/sbom-action/git/ref/tags/v0
    • Triggering command: /usr/bin/gh gh api /repos/anchore/sbom-action/git/ref/tags/v0 --jq .object.sha (http block)
  • https://api.github.com/repos/docker/build-push-action/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/docker/build-push-action/git/ref/tags/v6 --jq .object.sha (http block)
  • https://api.github.com/repos/docker/login-action/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/docker/login-action/git/ref/tags/v3 --jq .object.sha (http block)
  • https://api.github.com/repos/docker/metadata-action/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/docker/metadata-action/git/ref/tags/v5 --jq .object.sha (http block)
  • https://api.github.com/repos/docker/setup-buildx-action/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/docker/setup-buildx-action/git/ref/tags/v3 --jq .object.sha (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/c4e091835c7a94dc7d3acb8ed3ae145afb4995f3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/c4e091835c7a94dc7d3acb8ed3ae145afb4995f3 --jq .object.sha (http block)
  • https://api.github.com/repos/githubnext/agentics/git/ref/tags/-
    • Triggering command: /usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/- --jq .object.sha (http block)
  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

}{
{
name: "github_pages_repo",
repoName: "samueltauil.github.io",
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot anonymize user name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anonymized usernames in test cases. Changed samueltauil.github.io to testuser.github.io and username.github.io to anotheruser.github.io. (7042df5)

Replace real username 'samueltauil' with generic 'testuser' and 'username' with 'anotheruser' in TestRuntimeImportPathGitHubIO test cases

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan February 15, 2026 02:11
@pelikhan pelikhan marked this pull request as ready for review February 15, 2026 02:30
Copilot AI review requested due to automatic review settings February 15, 2026 02:30
Copy link
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

Fixes incorrect runtime-import path extraction when compiling workflows in repositories whose names include .github substrings (notably *.github.io), by switching to a directory-component match for /.github/. Adds a focused unit test to cover GitHub Pages-style repository paths.

Changes:

  • Update runtime-import path extraction to match the /.github/ directory component (after normalizing path separators).
  • Add TestRuntimeImportPathGitHubIO to validate correct runtime-import path generation for *.github.io and similar repo names.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/workflow/compiler_yaml.go Adjusts runtime-import path extraction logic to avoid substring matches like .github.io.
pkg/workflow/compiler_yaml_test.go Adds regression tests for runtime-import path generation in .github.io repo paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

workflowFilePath = workflowBasename
}
// +1 to skip the leading slash, so we get ".github/workflows/..." not "/.github/workflows/..."
workflowFilePath = normalizedPath[githubIndex+1:]
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

The new pattern search only matches paths containing "/.github/" (with a leading slash). If the compiler is invoked with a repository-relative path like ".github/workflows/test.md" (common in CLI flows that glob ".github/workflows/*.md"), githubIndex will be -1 and this will fall back to workflowBasename, producing a runtime-import like {{#runtime-import test.md}} instead of .github/workflows/test.md.

Suggested fix: support .github/ at the start of the normalized path (and optionally ./.github/) in addition to matching /.github/ as a directory boundary (e.g., match (^|/)\.github/ after filepath.ToSlash).

Suggested change
workflowFilePath = normalizedPath[githubIndex+1:]
workflowFilePath = normalizedPath[githubIndex+1:]
} else if strings.HasPrefix(normalizedPath, ".github/") {
// Handle repository-relative paths like ".github/workflows/test.md"
workflowFilePath = normalizedPath
} else if strings.HasPrefix(normalizedPath, "./.github/") {
// Handle repository-relative paths with leading "./", like "./.github/workflows/test.md"
// Strip the leading "./" so the runtime-import path starts with ".github/"
workflowFilePath = normalizedPath[2:]

Copilot uses AI. Check for mistakes.
Comment on lines +1186 to +1189
// Compile the workflow
compiler := NewCompiler()
if err := compiler.CompileWorkflow(workflowPath); err != nil {
t.Fatalf("%s: Compilation failed: %v", tt.description, err)
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

This test only exercises compilation when workflowPath is an absolute path (TempDir + filepath.Join). Since the runtime-import extraction logic depends on how c.markdownPath is formatted, it would be good to add a subtest that compiles the same workflow via a repo-relative path like ".github/workflows/.md" (e.g., os.Chdir(tmpDir) then call CompileWorkflow with the relative path). That would guard against regressions in CLI code paths that pass relative paths.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 9c7d4f4 into main Feb 15, 2026
92 checks passed
@pelikhan pelikhan deleted the copilot/fix-runtime-import-path branch February 15, 2026 02:42
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.

gh aw compile generates incorrect runtime-import path for repos ending in .github.io

2 participants