From c8cbd662e8deebf6303b289e850e0112e550dc04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 10:58:58 +0000 Subject: [PATCH] fix: improve upload_artifact error diagnostics and workflow staging instructions - Enhanced error message when path not found in staging directory to list available files or indicate the directory is empty, helping diagnose whether the agent forgot to copy files or used the wrong path - Updated api-consumption-report.md Step 5 with explicit shell commands for staging chart files and correct path format guidance - Addresses 3 consecutive daily failures (runs 6-8) caused by the AI agent not copying charts to the staging directory before calling upload_artifact Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3240af67-1ba1-4b22-91cf-a5b20c589d5b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/api-consumption-report.md | 19 ++++++++++++++++++- actions/setup/js/upload_artifact.cjs | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api-consumption-report.md b/.github/workflows/api-consumption-report.md index ac2e0b2b6b9..f89b62bfdaa 100644 --- a/.github/workflows/api-consumption-report.md +++ b/.github/workflows/api-consumption-report.md @@ -301,7 +301,24 @@ Use `sns.set_theme(style="darkgrid")` for a professional dark-grid look and `plt ## Step 5 — Upload Charts as Artifacts -Stage each successfully generated chart from `/tmp/gh-aw/python/charts/*.png` into `/tmp/gh-aw/safeoutputs/upload-artifacts/`, then call the `upload_artifact` safe-output tool for each chart. Collect and record the returned `aw_*` ID for each chart. +**You MUST copy the chart files to the staging directory before calling `upload_artifact`.** + +The `upload_artifact` tool only reads files from `/tmp/gh-aw/safeoutputs/upload-artifacts/`. Run these commands first: + +```bash +mkdir -p /tmp/gh-aw/safeoutputs/upload-artifacts/ +cp /tmp/gh-aw/python/charts/*.png /tmp/gh-aw/safeoutputs/upload-artifacts/ +``` + +Then verify the files are in the staging directory: + +```bash +ls -la /tmp/gh-aw/safeoutputs/upload-artifacts/ +``` + +After confirming the files exist in the staging directory, call `upload_artifact` for each chart using the **filename only** (not a subdirectory path). For example, use `path: "api_calls_trend.png"` — NOT `path: "charts/api_calls_trend.png"`. + +Call `upload_artifact` once per chart (5 total). Collect and record the returned `aw_*` ID for each chart. --- diff --git a/actions/setup/js/upload_artifact.cjs b/actions/setup/js/upload_artifact.cjs index e57eff0b477..eb4d34eacb4 100644 --- a/actions/setup/js/upload_artifact.cjs +++ b/actions/setup/js/upload_artifact.cjs @@ -142,7 +142,12 @@ function resolveFiles(request, allowedPaths, defaultInclude, defaultExclude) { return { files: [], error: `path must not traverse outside staging directory: ${reqPath}` }; } if (!fs.existsSync(resolved)) { - return { files: [], error: `path does not exist in staging directory: ${reqPath}` }; + const available = listFilesRecursive(STAGING_DIR, STAGING_DIR); + const hint = + available.length > 0 + ? ` Available files: [${available.slice(0, 20).join(", ")}]${available.length > 20 ? ` … and ${available.length - 20} more` : ""}` + : " The staging directory is empty — did you forget to copy files to " + STAGING_DIR + "?"; + return { files: [], error: `path does not exist in staging directory: ${reqPath}.${hint}` }; } const stat = fs.lstatSync(resolved); if (stat.isSymbolicLink()) {