Skip to content

Commit 356ba52

Browse files
amrit110claude
andcommitted
Fix classifier GitHub Actions output format
Use heredoc delimiters for multiline fields (reasoning, recommended-action) to prevent GitHub Actions parsing errors from special characters and newlines. Fixes: Invalid format error in fix-remote-pr.yml workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent dd52793 commit 356ba52

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/aieng_bot/_cli/commands/classify.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,28 @@ def _output_results(
4646
}
4747
console.print_json(data=output)
4848
else: # github format - output for GITHUB_OUTPUT
49-
# Escape special characters to prevent bash interpretation
50-
# Replace backticks, dollar signs, and double quotes
51-
def escape_for_bash(s: str) -> str:
52-
return (
53-
s.replace("\\", "\\\\")
54-
.replace("`", "\\`")
55-
.replace("$", "\\$")
56-
.replace('"', '\\"')
57-
)
58-
59-
reasoning_escaped = escape_for_bash(result.reasoning)
60-
action_escaped = escape_for_bash(result.recommended_action)
49+
# Use GitHub Actions heredoc delimiter format for multiline values
50+
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
6151

6252
# Create a stdout console for GitHub Actions output (stderr console is used for logging)
6353
stdout_console = Console(stderr=False, highlight=False)
6454

65-
# Output to stdout for GitHub Actions to capture
55+
# Simple values can use key=value format
6656
stdout_console.print(f"failure-type={result.failure_type.value}")
6757
stdout_console.print(f"confidence={result.confidence}")
68-
stdout_console.print(f"reasoning={reasoning_escaped}")
6958
stdout_console.print(
7059
f"failed-check-names={','.join(result.failed_check_names)}"
7160
)
72-
stdout_console.print(f"recommended-action={action_escaped}")
61+
62+
# Use heredoc delimiter for potentially multiline fields
63+
# This prevents issues with special characters and newlines
64+
stdout_console.print("reasoning<<EOF_REASONING")
65+
stdout_console.print(result.reasoning)
66+
stdout_console.print("EOF_REASONING")
67+
68+
stdout_console.print("recommended-action<<EOF_ACTION")
69+
stdout_console.print(result.recommended_action)
70+
stdout_console.print("EOF_ACTION")
7371

7472

7573
def _log_summary(result: ClassificationResult) -> None:

0 commit comments

Comments
 (0)