comment#23
Conversation
WalkthroughThe webhook handler is enhanced to extract a pre-formatted comment from the LLM model response, post it directly to the GitHub PR via the PR comments API with error handling, and update the email body to reference this comment instead of embedding the raw model response. Existing webhook verification and LLM processing flows are preserved. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
backend/controllers/webhook/handleWebhook.js (2)
101-101: Consider cleaning up this debug log
console.log("preparation started");//looks like temporary debugging (and the trailing//suggests leftover noise). Either remove it or make the message more specific if you intend to keep it.
166-166: Remove commented-out debug logThis commented
console.logis dead code now. To keep the handler lean, consider removing it or reintroducing logging behind a proper debug flag if still useful.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
backend/controllers/webhook/handleWebhook.js(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
backend/controllers/webhook/handleWebhook.js (1)
backend/utils/sendEmail.js (1)
sendEmail(12-23)
🔇 Additional comments (1)
backend/controllers/webhook/handleWebhook.js (1)
168-172: Good defensive default for missingformatted_commentUsing
modelResp.data?.formatted_commentwith a clear fallback string ensures the flow doesn’t break if the model omitsformatted_comment, and the user still gets a sensible message.
| // --- Post a comment on the PR --- | ||
| try { | ||
| await axios.post( | ||
| pr.comments_url, | ||
| { body: commentText }, | ||
| { headers: ghHeaders } | ||
| ); | ||
| console.log(`Comment posted on PR #${pr.number}`); | ||
| } catch (err) { | ||
| console.error("Failed to post PR comment:", err.message); | ||
| } |
There was a problem hiding this comment.
Email claims PR comment was added even if posting the comment fails
Right now, failures in axios.post(pr.comments_url, ...) are caught and only logged, but the completion email always says “We’ve added a comment to your PR…” and includes ${commentText}. If the GitHub comment post fails, this message becomes misleading.
You can track whether the comment was actually posted and branch the email text accordingly:
- // --- Post a comment on the PR ---
- try {
- await axios.post(
- pr.comments_url,
- { body: commentText },
- { headers: ghHeaders }
- );
- console.log(`Comment posted on PR #${pr.number}`);
- } catch (err) {
- console.error("Failed to post PR comment:", err.message);
- }
+ // --- Post a comment on the PR ---
+ let commentPosted = false;
+ try {
+ await axios.post(
+ pr.comments_url,
+ { body: commentText },
+ { headers: ghHeaders }
+ );
+ commentPosted = true;
+ console.log(`Comment posted on PR #${pr.number}`);
+ } catch (err) {
+ console.error("Failed to post PR comment:", err.message);
+ }
@@
- sendEmail({
- to: userEmail,
- subject: `[PullShark] Analysis complete`,
- text: `Your analysis is complete. We've added a comment to your PR with the details.\n\n${commentText}`,
- }).catch(() => {});
+ sendEmail({
+ to: userEmail,
+ subject: `[PullShark] Analysis complete`,
+ text: commentPosted
+ ? `Your analysis is complete. We've added a comment to your PR with the details.\n\n${commentText}`
+ : `Your analysis is complete, but we could not add a comment to your PR automatically. Here's the analysis:\n\n${commentText}`,
+ }).catch(() => {});This keeps the email accurate in both success and failure cases.
Also applies to: 190-191
Summary by CodeRabbit
Release Notes
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.