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
5 changes: 5 additions & 0 deletions .changeset/patch-fail-claude-no-log-entries.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions actions/setup/js/log_parser_bootstrap.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ async function runLogParser(options) {
core.error(`Failed to parse ${parserName} log`);
}

// Claude-specific guardrail: if no structured log entries were parsed, treat as execution failure.
// This catches silent startup failures where Claude exits before producing JSON tool activity.
if (parserName === "Claude" && (!logEntries || logEntries.length === 0)) {
core.setFailed("Claude execution failed: no structured log entries were produced. This usually indicates a startup or configuration error before tool execution.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Good safeguard! This prevents silent failures where Claude exits before tool execution.

}
Comment on lines +214 to +216
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The success message "Claude log parsed successfully" is logged on line 182 before the failure check on line 214. This creates a confusing situation where Claude logs indicate success, then immediately fail the run. The check for empty logEntries should happen earlier, before any success messages are logged, or the success message should be conditional to avoid this contradiction.

Copilot uses AI. Check for mistakes.

// Handle MCP server failures if present
if (mcpFailures && mcpFailures.length > 0) {
const failedServers = mcpFailures.join(", ");
Expand Down
16 changes: 16 additions & 0 deletions actions/setup/js/log_parser_bootstrap.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ describe("log_parser_bootstrap.cjs", () => {
fs.unlinkSync(logFile),
fs.rmdirSync(tmpDir));
}),
it("should fail Claude runs when no structured log entries are parsed", () => {
const tmpDir = fs.mkdtempSync(path.join(__dirname, "test-"));
const logFile = path.join(tmpDir, "test.log");
try {
fs.writeFileSync(logFile, "unstructured log output");
process.env.GH_AW_AGENT_OUTPUT = logFile;
const mockParseLog = vi.fn().mockReturnValue({ markdown: "## Result\n", mcpFailures: [], maxTurnsHit: false, logEntries: [] });
runLogParser({ parseLog: mockParseLog, parserName: "Claude" });
expect(mockCore.setFailed).toHaveBeenCalledWith(
"Claude execution failed: no structured log entries were produced. This usually indicates a startup or configuration error before tool execution."
);
} finally {
fs.unlinkSync(logFile);
fs.rmdirSync(tmpDir);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Test coverage for the zero-entries guardrail ensures silent failures are caught.

}),
it("should generate plain text summary when logEntries are available", () => {
const tmpDir = fs.mkdtempSync(path.join(__dirname, "test-")),
logFile = path.join(tmpDir, "test.log");
Expand Down
5 changes: 5 additions & 0 deletions actions/setup/js/parse_claude_log.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ describe("parse_claude_log.cjs", () => {
expect(mockCore.info).toHaveBeenCalledWith("No agent log file specified");
expect(mockCore.setFailed).not.toHaveBeenCalled();
});

it("should fail when Claude log has no structured entries", async () => {
await runScript("this is not structured Claude JSON output");
expect(mockCore.setFailed).toHaveBeenCalledWith("Claude execution failed: no structured log entries were produced. This usually indicates a startup or configuration error before tool execution.");
});
});

describe("helper function tests", () => {
Expand Down