feat: add automated bug-fixing GitHub Actions workflow and non-interactive CLI support#29
feat: add automated bug-fixing GitHub Actions workflow and non-interactive CLI support#29sasikumar161106 wants to merge 2 commits into
Conversation
|
📝 WalkthroughWalkthroughAdds a new GitHub Actions workflow that triggers an autonomous agent on ChangesAgent Auto-Fix Workflow and CI Support
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Analysis CompleteGenerated ECC bundle from 2 commits | Confidence: 50% View Pull Request #30Repository Profile
Changed Files (3)
Top hotspots
Top directories
Analysis Depth Readiness (commit-history, 21%)ECC Tools uses this to decide whether recommendations should stay at commit-history/setup guidance or expand into CI, security, harness, reference-set, AI-routing, and team backlog work.
Reference Set Readiness (0/7, 0%)
Likely Future Issues (3)
Suggested Follow-up Work (3)
Copy-ready bodies test: add regression coverage for main.py + modules/agent_loop.py ## Summary
- Add regression coverage for the recently touched code paths before more changes stack on top.
## Why
- Backfill regression coverage before another change set lands on the touched code paths.
## Touched paths
- `main.py`
- `modules/agent_loop.py`
## Validation
- Add or extend focused tests that exercise the touched paths.
- Run the affected test suite and verify the new coverage closes the gap.ci: add failure-mode evidence for .github/workflows/agent-fix.yml ## Summary
- Add CI failure-mode evidence for the recently changed workflow or test-runner surface.
## Why
- Backfill CI failure-mode evidence before another workflow or test-runner change lands on the touched surface.
## Touched paths
- `.github/workflows/agent-fix.yml`
## Validation
- Add or update a CI failure fixture, captured failing log, troubleshooting note, workflow dry-run evidence, or regression test for the changed CI/test-runner behavior.
- Run the affected workflow or test-runner entrypoint locally or in CI and record pass/fail evidence.chore: refresh lockfile and validate CI after dependency updates ## Summary
- Refresh the lockfile and rerun CI after the dependency or workflow changes in this PR.
## Why
- Package or workflow changes without a lockfile refresh tend to turn into noisy follow-up fixes after merge.
## Touched paths
- `.github/workflows/agent-fix.yml`
## Validation
- Refresh the lockfile in the same package manager used by the repo.
- Run the repo typecheck / test / CI entrypoints that depend on the updated package graph.Generated Instincts (15)
After merging, import with: Files
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/agent-fix.yml:
- Around line 70-79: The success comment in the workflow still claims a Pull
Request was created even when prUrl is empty. Update the success branch in
agent-fix.yml so the message that includes the Pull Request link only runs when
both outcome === "success" and prUrl is present; otherwise fall back to a
message that does not mention a PR. Use the existing outcome, prUrl,
commentBody, and runId variables to locate and gate the logic.
- Around line 71-88: The multi-line template literals assigned to commentBody
inside the workflow’s script block are not indented correctly for YAML, causing
the block scalar to break. Update the strings in the agent-fix workflow so the
lines within each backtick template remain consistently indented under script:
|, and verify both the success and failure branches in the commentBody
assignment preserve valid YAML parsing.
- Around line 63-66: The github-script interpolation in the agent-fix workflow
is using raw step outputs, which can break the script or become unsafe when the
output contains quotes/newlines. Update the script block that reads the
run-agent outputs (outcome, pr_url, run_id, final_message) to serialize each
value with toJSON() before assigning to variables, and ensure the existing
github-script snippet still uses those symbols safely.
In `@main.py`:
- Around line 124-133: The pre-run validation exits in main() currently call
sys.exit(1) before the try block, so GitHub Actions never receives failure
outputs. Update the repo_root and task validation paths in main.py to write the
expected GitHub outputs before exiting, using the same output-writing mechanism
already used for run-agent outcomes so CI consumers see an error state instead
of empty steps.run-agent.outputs.* values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 92358971-4254-4da6-b521-428653f0c1da
📒 Files selected for processing (3)
.github/workflows/agent-fix.ymlmain.pymodules/agent_loop.py
| const outcome = "${{ steps.run-agent.outputs.outcome }}"; | ||
| const prUrl = "${{ steps.run-agent.outputs.pr_url }}"; | ||
| const runId = "${{ steps.run-agent.outputs.run_id }}"; | ||
| const message = "${{ steps.run-agent.outputs.final_message }}"; |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n '\$\{\{\s*steps\.run-agent\.outputs\.' .github/workflows/agent-fix.ymlRepository: sreerevanth/repopilot
Length of output: 451
🏁 Script executed:
#!/bin/bash
sed -n '1,220p' .github/workflows/agent-fix.ymlRepository: sreerevanth/repopilot
Length of output: 3135
🏁 Script executed:
#!/bin/bash
rg -n "final_message|pr_url|run_id|outcome" -S .Repository: sreerevanth/repopilot
Length of output: 7332
🏁 Script executed:
#!/bin/bash
sed -n '150,230p' main.pyRepository: sreerevanth/repopilot
Length of output: 2220
🏁 Script executed:
#!/bin/bash
rg -n "def write_github_output|write_github_output\(" -S .Repository: sreerevanth/repopilot
Length of output: 355
🏁 Script executed:
#!/bin/bash
sed -n '90,120p' main.pyRepository: sreerevanth/repopilot
Length of output: 1216
🏁 Script executed:
#!/bin/bash
sed -n '396,414p' modules/agent_loop.pyRepository: sreerevanth/repopilot
Length of output: 1096
Quote the step outputs before interpolating them into github-script. Raw substitution is evaluated as JS here; final_message can carry arbitrary text on the error path, so quotes/newlines can break the script and turn into code execution. Use toJSON() for all four outputs.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/agent-fix.yml around lines 63 - 66, The github-script
interpolation in the agent-fix workflow is using raw step outputs, which can
break the script or become unsafe when the output contains quotes/newlines.
Update the script block that reads the run-agent outputs (outcome, pr_url,
run_id, final_message) to serialize each value with toJSON() before assigning to
variables, and ensure the existing github-script snippet still uses those
symbols safely.
| if (outcome === "success") { | ||
| commentBody = `Hello @${issuee}, | ||
|
|
||
| I have successfully fixed the issue! 🎉 | ||
|
|
||
| A Pull Request has been created with the changes: | ||
| 🔗 **[Pull Request](${prUrl})** | ||
|
|
||
| **Run ID:** \`${runId}\` | ||
| **Message:** ${message}`; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not claim a PR was created when pr_url is empty.
outcome === "success" only means the agent completed/tests passed; pr_url can still be empty if push or PR creation fails. Gate this branch on prUrl too.
Proposed fix
- if (outcome === "success") {
+ if (outcome === "success" && prUrl) {
commentBody = `Hello @${issuee},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (outcome === "success") { | |
| commentBody = `Hello @${issuee}, | |
| I have successfully fixed the issue! 🎉 | |
| A Pull Request has been created with the changes: | |
| 🔗 **[Pull Request](${prUrl})** | |
| **Run ID:** \`${runId}\` | |
| **Message:** ${message}`; | |
| if (outcome === "success" && prUrl) { | |
| commentBody = `Hello @${issuee}, | |
| I have successfully fixed the issue! 🎉 | |
| A Pull Request has been created with the changes: | |
| 🔗 **[Pull Request](${prUrl})** | |
| **Run ID:** \`${runId}\` | |
| **Message:** ${message}`; |
🧰 Tools
🪛 actionlint (1.7.12)
[error] 73-73: could not parse as YAML: could not find expected ':'
(syntax-check)
🪛 YAMLlint (1.37.1)
[error] 75-75: syntax error: could not find expected ':'
(syntax)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/agent-fix.yml around lines 70 - 79, The success comment in
the workflow still claims a Pull Request was created even when prUrl is empty.
Update the success branch in agent-fix.yml so the message that includes the Pull
Request link only runs when both outcome === "success" and prUrl is present;
otherwise fall back to a message that does not mention a PR. Use the existing
outcome, prUrl, commentBody, and runId variables to locate and gate the logic.
| commentBody = `Hello @${issuee}, | ||
|
|
||
| I have successfully fixed the issue! 🎉 | ||
|
|
||
| A Pull Request has been created with the changes: | ||
| 🔗 **[Pull Request](${prUrl})** | ||
|
|
||
| **Run ID:** \`${runId}\` | ||
| **Message:** ${message}`; | ||
| } else { | ||
| commentBody = `Hello @${issuee}, | ||
|
|
||
| I attempted to fix this issue automatically but encountered a problem. | ||
|
|
||
| **Outcome:** \`${outcome || 'unknown/failed'}\` | ||
| **Message:** ${message || 'No additional message was provided.'} | ||
|
|
||
| Please check the GitHub Actions workflow logs for more details.`; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
if command -v actionlint >/dev/null; then
actionlint .github/workflows/agent-fix.yml
fi
if command -v yamllint >/dev/null; then
yamllint .github/workflows/agent-fix.yml
fiRepository: sreerevanth/repopilot
Length of output: 854
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the relevant workflow section with line numbers.
sed -n '55,100p' .github/workflows/agent-fix.yml | cat -n
# Also show the surrounding job/step structure to confirm the YAML nesting.
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/agent-fix.yml')
for i, line in enumerate(p.read_text().splitlines(), 1):
if 50 <= i <= 105:
print(f"{i:4}: {line}")
PYRepository: sreerevanth/repopilot
Length of output: 3701
Indent the template literal body inside script: |
The unindented lines in both multi-line strings break the YAML block and prevent the workflow from parsing.
🧰 Tools
🪛 actionlint (1.7.12)
[error] 73-73: could not parse as YAML: could not find expected ':'
(syntax-check)
🪛 YAMLlint (1.37.1)
[error] 75-75: syntax error: could not find expected ':'
(syntax)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/agent-fix.yml around lines 71 - 88, The multi-line
template literals assigned to commentBody inside the workflow’s script block are
not indented correctly for YAML, causing the block scalar to break. Update the
strings in the agent-fix workflow so the lines within each backtick template
remain consistently indented under script: |, and verify both the success and
failure branches in the commentBody assignment preserve valid YAML parsing.
Source: Linters/SAST tools
| if not os.path.isdir(repo_root): | ||
| print(f"ERROR: Repository path does not exist: {repo_root}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| yes_flag = args.yes or os.environ.get("CI") == "true" | ||
|
|
||
| task = args.task or os.environ.get("AGENT_TASK") | ||
| if not task: | ||
| print("ERROR: Task description is required. Provide --task or set the AGENT_TASK environment variable.", file=sys.stderr) | ||
| sys.exit(1) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Write GitHub outputs for pre-run validation failures.
These sys.exit(1) paths run before the try block, so CI consumers get empty steps.run-agent.outputs.* instead of outcome=error.
Proposed fix
if not os.path.isdir(repo_root):
- print(f"ERROR: Repository path does not exist: {repo_root}", file=sys.stderr)
+ message = f"Repository path does not exist: {repo_root}"
+ print(f"ERROR: {message}", file=sys.stderr)
+ write_github_output({
+ "outcome": "error",
+ "run_id": "",
+ "iterations": "0",
+ "branch_name": "",
+ "pr_url": "",
+ "final_message": message,
+ })
sys.exit(1)
yes_flag = args.yes or os.environ.get("CI") == "true"
task = args.task or os.environ.get("AGENT_TASK")
if not task:
- print("ERROR: Task description is required. Provide --task or set the AGENT_TASK environment variable.", file=sys.stderr)
+ message = "Task description is required. Provide --task or set the AGENT_TASK environment variable."
+ print(f"ERROR: {message}", file=sys.stderr)
+ write_github_output({
+ "outcome": "error",
+ "run_id": "",
+ "iterations": "0",
+ "branch_name": "",
+ "pr_url": "",
+ "final_message": message,
+ })
sys.exit(1)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if not os.path.isdir(repo_root): | |
| print(f"ERROR: Repository path does not exist: {repo_root}", file=sys.stderr) | |
| sys.exit(1) | |
| yes_flag = args.yes or os.environ.get("CI") == "true" | |
| task = args.task or os.environ.get("AGENT_TASK") | |
| if not task: | |
| print("ERROR: Task description is required. Provide --task or set the AGENT_TASK environment variable.", file=sys.stderr) | |
| sys.exit(1) | |
| if not os.path.isdir(repo_root): | |
| message = f"Repository path does not exist: {repo_root}" | |
| print(f"ERROR: {message}", file=sys.stderr) | |
| write_github_output({ | |
| "outcome": "error", | |
| "run_id": "", | |
| "iterations": "0", | |
| "branch_name": "", | |
| "pr_url": "", | |
| "final_message": message, | |
| }) | |
| sys.exit(1) | |
| yes_flag = args.yes or os.environ.get("CI") == "true" | |
| task = args.task or os.environ.get("AGENT_TASK") | |
| if not task: | |
| message = "Task description is required. Provide --task or set the AGENT_TASK environment variable." | |
| print(f"ERROR: {message}", file=sys.stderr) | |
| write_github_output({ | |
| "outcome": "error", | |
| "run_id": "", | |
| "iterations": "0", | |
| "branch_name": "", | |
| "pr_url": "", | |
| "final_message": message, | |
| }) | |
| sys.exit(1) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@main.py` around lines 124 - 133, The pre-run validation exits in main()
currently call sys.exit(1) before the try block, so GitHub Actions never
receives failure outputs. Update the repo_root and task validation paths in
main.py to write the expected GitHub outputs before exiting, using the same
output-writing mechanism already used for run-agent outcomes so CI consumers see
an error state instead of empty steps.run-agent.outputs.* values.
|
@sasikumar161106 please check the merge conflicts |
This PR adds a GitHub Actions workflow to automatically run the developer agent on issues labeled with \�gent-fix. It also updates the agent to support non-interactive executions via a new --yes\ flag and reports outcomes to $GITHUB_OUTPUT.
Summary by CodeRabbit