Skip to content

Commit 9d5b958

Browse files
committed
fix: Remove illegal return statements from top-level code in agent.mjs
- Removed return statements outside functions (not allowed in ES modules) - handleError already calls process.exit(1), so returns are unnecessary - Fixes SyntaxError: Illegal return statement
1 parent 9bba7ba commit 9d5b958

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

.github/agent/agent.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ try {
213213
output = await callAI(prompt);
214214
} catch (error) {
215215
await handleError(error, `${provider.toUpperCase()} API Error`);
216-
return; // Exit already handled
216+
// handleError calls process.exit(1), so we never reach here
217217
}
218218

219219
// Extract diff from potential markdown code blocks
@@ -230,7 +230,7 @@ if (output.includes("```")) {
230230
if (!diff.includes("diff --git")) {
231231
const errorMsg = `Model did not return a valid diff. Output was:\n\`\`\`\n${output.substring(0, 500)}\n\`\`\``;
232232
await handleError(new Error(errorMsg), "Invalid Diff Format");
233-
return;
233+
// handleError calls process.exit(1), so we never reach here
234234
}
235235

236236
// Safety check: Ensure we're not touching forbidden files
@@ -248,7 +248,7 @@ for (const pattern of forbiddenPatterns) {
248248
new Error(`Attempted to modify forbidden file matching ${pattern}`),
249249
"Safety Violation"
250250
);
251-
return;
251+
// handleError calls process.exit(1), so we never reach here
252252
}
253253
}
254254

@@ -259,7 +259,7 @@ if (linesChanged > 300) {
259259
new Error(`Too many lines changed (${linesChanged} > 300). Maximum allowed is 300 lines.`),
260260
"Safety Violation"
261261
);
262-
return;
262+
// handleError calls process.exit(1), so we never reach here
263263
}
264264

265265
console.log(`[AGENT] Generated diff with ${linesChanged} lines changed`);
@@ -273,7 +273,7 @@ try {
273273
} catch (err) {
274274
const errorMsg = `Failed to apply patch: ${err.message}\n\nDiff preview:\n\`\`\`\n${diff.substring(0, 500)}\n\`\`\``;
275275
await handleError(new Error(errorMsg), "Patch Application Failed");
276-
return;
276+
// handleError calls process.exit(1), so we never reach here
277277
}
278278

279279
// Show diff for logs

0 commit comments

Comments
 (0)