From 9783bcf64deace619b0677c3e427729adfa914b8 Mon Sep 17 00:00:00 2001 From: wangzhizhou <824219521@qq.com> Date: Tue, 10 Nov 2026 14:03:28 +0800 Subject: [PATCH] fix(ai-run): GITHUB_REPOSITORY is reserved; artifact names cannot contain "/" Two bugs found by dispatching ai-run.yml for real: - `GITHUB_REPOSITORY` cannot be overridden via `env:` (GitHub reserves GITHUB_*), so the runner saw the hub repo instead of the target and failed to read the issue. Add `AI_TARGET_REPO` (read first by main.ts) and set it in ai-run.yml. - the artifact name embedded `owner/repo`, which upload-artifact rejects (forward slash is not allowed) -> use issue + run id. --- .github/workflows/ai-run.yml | 6 ++++-- agent-runner/src/main.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ai-run.yml b/.github/workflows/ai-run.yml index a639501..2f1b29c 100644 --- a/.github/workflows/ai-run.yml +++ b/.github/workflows/ai-run.yml @@ -85,7 +85,9 @@ jobs: - name: Run the agent runner env: GH_TOKEN: ${{ steps.mint.outputs.token }} - GITHUB_REPOSITORY: ${{ inputs.repo }} + # GITHUB_REPOSITORY is reserved and cannot be overridden by env:; + # the runner reads AI_TARGET_REPO first. + AI_TARGET_REPO: ${{ inputs.repo }} ISSUE_NUMBER: ${{ inputs.issue }} WORK_DIR: ${{ env.WORK_DIR }} DEFAULT_BRANCH: ${{ env.DEFAULT_BRANCH }} @@ -117,7 +119,7 @@ jobs: if: always() uses: actions/upload-artifact@v7 with: - name: ai-run-${{ inputs.repo }}-${{ inputs.issue }} + name: ai-run-${{ inputs.issue }}-${{ github.run_id }} path: ${{ runner.temp }}/ai-issue-${{ inputs.issue }} if-no-files-found: ignore retention-days: 7 diff --git a/agent-runner/src/main.ts b/agent-runner/src/main.ts index 5ade8c4..c938c92 100644 --- a/agent-runner/src/main.ts +++ b/agent-runner/src/main.ts @@ -166,7 +166,9 @@ function riskLine(risk: RiskAssessment | null): string { } async function main(): Promise { - const repo = requireEnv("GITHUB_REPOSITORY"); + // `AI_TARGET_REPO` is for workflows that cannot override the reserved + // GITHUB_REPOSITORY variable (ai-run.yml runs one task for a foreign repo). + const repo = process.env.AI_TARGET_REPO?.trim() || requireEnv("GITHUB_REPOSITORY"); const issueNumber = Number(requireEnv("ISSUE_NUMBER")); if (!Number.isInteger(issueNumber) || issueNumber <= 0) throw new Error(`Bad ISSUE_NUMBER: ${process.env.ISSUE_NUMBER}`);