Skip to content

Fix validate_errors.cjs to handle missing logs folder gracefully#1794

Merged
pelikhan merged 2 commits intomainfrom
copilot/validate-logs-folder-existence
Oct 16, 2025
Merged

Fix validate_errors.cjs to handle missing logs folder gracefully#1794
pelikhan merged 2 commits intomainfrom
copilot/validate-logs-folder-existence

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 16, 2025

Problem

The validate_errors.cjs script was throwing an error when the logs folder doesn't exist, causing workflow failures:

Error: Log path not found: /tmp/gh-aw/.copilot/logs/
    at main (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v8/dist/index.js:36187:16), <anonymous>:15:13)

This occurred because:

  1. The Copilot engine sets GITHUB_AW_AGENT_OUTPUT to /tmp/gh-aw/.copilot/logs/ (a directory)
  2. The validation step runs unconditionally with if: always()
  3. If no logs were generated or the directory doesn't exist yet, the script would fail

Solution

Modified the error handling in validate_errors.cjs to gracefully handle missing log paths by logging an informational message and returning early, rather than throwing an error:

Before:

if (!fs.existsSync(logPath)) {
  throw new Error(`Log path not found: ${logPath}`);
}

After:

if (!fs.existsSync(logPath)) {
  core.info(`Log path not found: ${logPath}`);
  core.info("No logs to validate - skipping error validation");
  return;
}

This approach:

  • Matches the behavior of parse_copilot_log.cjs, which handles the same scenario gracefully
  • Allows the validation step to complete successfully when there are no logs to validate
  • Provides clear informational messages about why validation was skipped
  • Prevents workflow failures when the logs directory legitimately doesn't exist

Testing

  • ✅ All JavaScript tests pass (31 tests in validate_errors.test.cjs)
  • ✅ All Go unit tests pass
  • make agent-finish validation completed successfully

Fixes the error reported in the issue where the validation step was failing due to a missing logs folder.

Original prompt

In the step that validates agent logs, make sure that the logs folder exists.

Run actions/github-script@v8
Error: Log path not found: /tmp/gh-aw/.copilot/logs/
    at main (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v8/dist/index.js:36187:16), <anonymous>:15:13)
    at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v8/dist/index.js:36187:16), <anonymous>:185:3)
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v8/dist/index.js:36188:12)
    at main (/home/runner/work/_actions/actions/github-script/v8/dist/index.js:36285:26)
    at /home/runner/work/_actions/actions/github-script/v8/dist/index.js:36260:1
    at /home/runner/work/_actions/actions/github-script/v8/dist/index.js:36317:3
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v8/dist/index.js:36320:12)
    at Module._compile (node:internal/modules/cjs/loader:1760:14)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
    at Module.load (node:internal/modules/cjs/loader:1480:32)
Error: Error validating log: Log path not found: /tmp/gh-aw/.copilot/logs/

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Validate existence of logs folder in agent logs Fix validate_errors.cjs to handle missing logs folder gracefully Oct 16, 2025
Copilot AI requested a review from pelikhan October 16, 2025 05:20
@pelikhan pelikhan marked this pull request as ready for review October 16, 2025 05:28
@pelikhan pelikhan merged commit 6907765 into main Oct 16, 2025
5 checks passed
@pelikhan pelikhan deleted the copilot/validate-logs-folder-existence branch October 16, 2025 05:28
@github-actions
Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request

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.

2 participants