Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/api-consumption-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
7 changes: 6 additions & 1 deletion actions/setup/js/upload_artifact.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "?";
Comment on lines +145 to +149
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The hint branch treats a missing staging directory the same as an empty one: listFilesRecursive() returns [] when STAGING_DIR doesn’t exist, so the message says “The staging directory is empty …” even though the directory may be missing. Consider checking fs.existsSync(STAGING_DIR) separately and using a more accurate hint (e.g., distinguish “does not exist” vs “is empty”).

Suggested change
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 + "?";
const stagingDirExists = fs.existsSync(STAGING_DIR);
const available = stagingDirExists ? 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` : ""}`
: stagingDirExists
? " The staging directory is empty — did you forget to copy files to " + STAGING_DIR + "?"
: " The staging directory does not exist — did you forget to create or populate " + STAGING_DIR + "?";

Copilot uses AI. Check for mistakes.
return { files: [], error: `path does not exist in staging directory: ${reqPath}.${hint}` };
}
const stat = fs.lstatSync(resolved);
if (stat.isSymbolicLink()) {
Expand Down
Loading