Conversation
Added AI-powered risk summary generation for PR readiness.
|
👋 Thanks for opening this pull request, @S3DFX-CYBER! Before your PR is reviewed, please ensure:
🔍 Our team will review your PR shortly. If you have questions, feel free to ask in the comments. 🚀 Keep up the great work! — OWASP BLT |
📊 Monthly LeaderboardHi @S3DFX-CYBER! Here's how you rank for March 2026:
Scoring this month (across OWASP-BLT org): Open PRs (+1 each), Merged PRs (+10), Closed (not merged) (−2), Reviews (+5; first two per PR in-month), Comments (+2, excludes CodeRabbit). Run |
🍃 PR Readiness CheckCheck the readiness of this PR on Leaf: Leaf reviews pull requests for operational readiness, security risks, and production-impacting changes before they ship. |
WalkthroughAdds a "Risk Summary" column to the PR table UI and augments PR readiness computation with a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
@coderabbitai why is one test failing |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1868 🏁 Script executed: Length of output: 1147 🏁 Script executed: Length of output: 1048
The Here's the problematic block: # ✅ 4-space indented (correct)
if merge_ready:
classification = 'READY_TO_MERGE'
...
return { # ❌ Only 2 spaces — should be 4 spaces
'overall_score': overall_score,
...
'risk_summary': generate_ai_risk_summary({...})
} # ❌ Closing brace also misalignedThe fix is to change the return {
'overall_score': overall_score,
'ci_score': ci_score,
'review_score': review_score,
'classification': classification,
'merge_ready': merge_ready,
'blockers': blockers,
'warnings': warnings,
'recommendations': recommendations,
'risk_summary': generate_ai_risk_summary({
'overall_score': overall_score,
'ci_score': ci_score,
'review_score': review_score,
'classification': classification,
'merge_ready': merge_ready,
'blockers': blockers,
'warnings': warnings,
'recommendations': recommendations
})
}This was likely introduced when the |
|
@coderabbitai can u apply this fixes to the appropriate files and provide me with the updated files so i can apply |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3586
return {
'overall_score': overall_score,
'ci_score': ci_score,
'review_score': review_score,
'classification': classification,
'merge_ready': merge_ready,
'blockers': blockers,
'warnings': warnings,
'recommendations': recommendations,
'risk_summary': generate_ai_risk_summary({
'overall_score': overall_score,
'ci_score': ci_score,
'review_score': review_score,
'classification': classification,
'merge_ready': merge_ready,
'blockers': blockers,
'warnings': warnings,
'recommendations': recommendations
})
}What changed:
This is the only change needed in |
|
@coderabbitai can u provide the updated utils.py with the fix , so i can apply |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 23965
📄 Updated
|
| Before | After |
|---|---|
··return { (2-space) |
····return { (4-space) |
····'overall_score': ... (4-space) |
········'overall_score': ... (8-space) |
| Inner dict keys at 8-space | Inner dict keys at 12-space |
Closing }) at 4-space, } at 0-space |
Closing }) at 8-space, } at 4-space |
Once you replace src/utils.py with this content and push, the Python syntax check should pass. 🐇✨
|
@coderabbitai why are tests still failing |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3677 🏁 Script executed: Length of output: 1764
🔴 Issue 1 — Still causing the
|
| Line | Current | Fix |
|---|---|---|
| 602 | `#Add` ai summary feat |
# Add AI summary feat (or delete) |
| 634–637 | call_gemini_api(prompt) in try/except |
Replace with return generate_fallback_summary(pr_readiness_data) |
Fix #1 will unblock the CI syntax check immediately. Fix #2 prevents a runtime crash once the feature is exercised. 🐇
|
👋 Hi @S3DFX-CYBER! This pull request needs a peer review before it can be merged. Please request a review from a team member who is not:
Once a valid peer review is submitted, this check will pass automatically. Thank you!
|
|
@coderabbitai why are the tests failing |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3558 🏁 Script executed: Length of output: 93633
Both jobs fail with the exact same error: This crashes ✅ What you need to do — two edits in
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/utils.py (1)
19-19: Backticks in docstrings/comments are harmless but inconsistent.The backticks around issue numbers (e.g.,
Issue \#45``) in comments are syntactically valid Python strings, but they introduce inconsistency with typical Python comment conventions. Consider removing the backticks for consistency:- Security Hardening (Issue `#45`): + Security Hardening (Issue `#45`):Also applies to: 24-24, 33-33, 38-38
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils.py` at line 19, Replace inconsistent backtick-wrapped issue references in comments/docstrings (e.g., the string "Security Hardening (Issue `#45`)" and the other occurrences showing backticks) by removing the backticks so they read "Issue `#45`" (and similarly for the other instances) to match normal Python comment/docstring conventions; update all occurrences in src/utils.py where issue numbers are enclosed in backticks so formatting is consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@public/index.html`:
- Around line 2712-2714: Add logic in the updateInlineCells function to populate
the cell with id readiness-risk-summary-${pr.id} using the API's
readiness.risk_summary: locate updateInlineCells (the block that updates the
Issues cell) and after that block get the element by id using the prId variable,
check readiness.risk_summary exists, then set innerHTML to a truncated, escaped
version (use the existing escapeHtml helper) and include a title attribute with
the full escaped text so long summaries show on hover.
- Around line 2381-2385: The TH element that defines the "Risk Summary" column
has a mismatched quote in the class attribute and a typo in the title; locate
the <th> element that includes attributes class, data-sort-column="risk_summary"
and title="AI-generated risk summmary for the PR" and fix the class attribute so
its opening and closing quotes match (use either both single or both double
quotes) and correct the title text from "summmary" to "summary" so the HTML
parses correctly.
In `@src/utils.py`:
- Around line 633-638: The try/except is calling an undefined function
call_gemini_api which will raise NameError and is masked by the exception
handler; replace the whole try/except so the function returns the deterministic
summary directly by invoking generate_fallback_summary(pr_readiness_data) (e.g.,
return generate_fallback_summary(pr_readiness_data)) and remove references to
ai_summary/call_gemini_api until a proper Gemini integration (and import) is
added.
---
Nitpick comments:
In `@src/utils.py`:
- Line 19: Replace inconsistent backtick-wrapped issue references in
comments/docstrings (e.g., the string "Security Hardening (Issue `#45`)" and the
other occurrences showing backticks) by removing the backticks so they read
"Issue `#45`" (and similarly for the other instances) to match normal Python
comment/docstring conventions; update all occurrences in src/utils.py where
issue numbers are enclosed in backticks so formatting is consistent.
🪄 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: Repository: OWASP-BLT/coderabbit/.coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 1761bb2e-8de1-4aa0-b2d0-e89340983cc0
📒 Files selected for processing (2)
public/index.htmlsrc/utils.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
@coderabbitai Missing JavaScript logic to populate the Risk Summary cell. The cell is created with id readiness-risk-summary-${pr.id} but the updateInlineCells function (around lines 3055-3157) does not update this cell with the risk_summary value from the API response. The cell will always show - |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 7588
Add this snippet after the Issues/Blockers block (after the // Update Risk Summary
const riskSummaryCell = document.getElementById(`readiness-risk-summary-${prId}`);
if (riskSummaryCell) {
const summary = readiness.risk_summary;
if (summary && summary.trim()) {
const colorClass = readiness.merge_ready
? 'text-emerald-700 dark:text-emerald-400'
: readiness.blockers && readiness.blockers.length > 0
? 'text-red-700 dark:text-red-400'
: 'text-amber-700 dark:text-amber-400';
riskSummaryCell.innerHTML = `
<span class="text-xs ${colorClass}" title="${escapeHtml(summary)}">
${escapeHtml(summary)}
</span>`;
} else {
riskSummaryCell.innerHTML = '<span class="text-xs text-slate-400">-</span>';
}
}What this does:
Where to insert it — in |
|
@coderabbitai can u show me where exactly i have to input the changes |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 4476
issuesHTML += '</div>';
issuesCell.innerHTML = issuesHTML;
}
} // ← this closes updateInlineCells (line 3158)👉 Insert the new code between the issuesHTML += '</div>';
issuesCell.innerHTML = issuesHTML;
} // ← line 3157: closes `if (issuesCell)` block
// ✅ INSERT NEW CODE HERE ↓
// Update Risk Summary
const riskSummaryCell = document.getElementById(`readiness-risk-summary-${prId}`);
if (riskSummaryCell) {
const summary = readiness.risk_summary;
if (summary && summary.trim()) {
const colorClass = readiness.merge_ready
? 'text-emerald-700 dark:text-emerald-400'
: readiness.blockers && readiness.blockers.length > 0
? 'text-red-700 dark:text-red-400'
: 'text-amber-700 dark:text-amber-400';
riskSummaryCell.innerHTML = `
<span class="text-xs ${colorClass}" title="${escapeHtml(summary)}">
${escapeHtml(summary)}
</span>`;
} else {
riskSummaryCell.innerHTML = '<span class="text-xs text-slate-400">-</span>';
}
}
// ✅ END OF NEW CODE ↑
} // ← line 3158: closes `updateInlineCells` function
function invalidateApiCache(path) { // ← next function starts hereVisual summary of the change:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@public/index.html`:
- Around line 3160-3178: The risk summary DOM update block currently runs at
module load and references an undefined pr (pr.id), causing a runtime error;
move that entire block into the updateInlineCells function and change references
from pr.id to prId (the function's parameter), locating the logic around
readiness, riskSummaryCell and escapeHtml so it uses the passed-in prId and the
existing readiness object inside updateInlineCells; ensure the fallback branch
remains the same but uses prId to build the element id
(`readiness-risk-summary-${prId}`) and keep colorClass computation and innerHTML
assignments unchanged.
🪄 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: Repository: OWASP-BLT/coderabbit/.coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 1e24b2d1-3b17-4a5a-ae8d-677cdc4e6bb8
📒 Files selected for processing (1)
public/index.html
| // Update Risk Summary | ||
| const riskSummaryCell = document.getElementById(`readiness-risk-summary-${pr.id}`); | ||
| if (riskSummaryCell) { | ||
| const summary = readiness.risk_summary; | ||
| if (summary && summary.trim()) { | ||
| const colorClass = readiness.merge_ready | ||
| ? 'text-emerald-700 dark:text-emerald-400' | ||
| : readiness.blockers && readiness.blockers.length > 0 | ||
| ? 'text-red-700 dark:text-red-400' | ||
| : 'text-amber-700 dark:text-amber-400'; | ||
| riskSummaryCell.innerHTML = ` | ||
| <span class="text-xs ${colorClass}" title="${escapeHtml(summary)}"> | ||
| ${escapeHtml(summary)} | ||
| </span>`; | ||
| } else { | ||
| riskSummaryCell.innerHTML = '<span class="text-xs text-slate-400">-</span>'; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Critical: Risk summary update block is outside updateInlineCells and uses undefined pr.
Line 3161 executes at script load and references pr.id, which triggers a runtime error. Move this block inside updateInlineCells and use prId.
🐛 Suggested fix
function updateInlineCells(prId, readiness, reviewHealth) {
@@
if (issuesCell) {
@@
issuesCell.innerHTML = issuesHTML;
}
- }
-
- // Update Risk Summary
- const riskSummaryCell = document.getElementById(`readiness-risk-summary-${pr.id}`);
+
+ // Update Risk Summary
+ const riskSummaryCell = document.getElementById(`readiness-risk-summary-${prId}`);
if (riskSummaryCell) {
const summary = readiness.risk_summary;
if (summary && summary.trim()) {
const colorClass = readiness.merge_ready
? 'text-emerald-700 dark:text-emerald-400'
: readiness.blockers && readiness.blockers.length > 0
? 'text-red-700 dark:text-red-400'
: 'text-amber-700 dark:text-amber-400';
riskSummaryCell.innerHTML = `
<span class="text-xs ${colorClass}" title="${escapeHtml(summary)}">
${escapeHtml(summary)}
</span>`;
} else {
riskSummaryCell.innerHTML = '<span class="text-xs text-slate-400">-</span>';
}
}
-
+ }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@public/index.html` around lines 3160 - 3178, The risk summary DOM update
block currently runs at module load and references an undefined pr (pr.id),
causing a runtime error; move that entire block into the updateInlineCells
function and change references from pr.id to prId (the function's parameter),
locating the logic around readiness, riskSummaryCell and escapeHtml so it uses
the passed-in prId and the existing readiness object inside updateInlineCells;
ensure the fallback branch remains the same but uses prId to build the element
id (`readiness-risk-summary-${prId}`) and keep colorClass computation and
innerHTML assignments unchanged.
|
@coderabbitai check for syntax issues and prId is not defined im getting some locally testing issues |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 28117
Here's exactly what your file looks like now vs. what it should be: Current (broken) — Lines 3155–3175: issuesHTML += '</div>';
issuesCell.innerHTML = issuesHTML;
}
} // ← updateInlineCells closes HERE (line ~3159)
// Update Risk Summary ← ❌ OUTSIDE the function!
const riskSummaryCell = document.getElementById(`readiness-risk-summary-${pr.id}`); // ← ❌ pr.id not in scope
if (riskSummaryCell) {
...
}Fixed — move the block inside issuesHTML += '</div>';
issuesCell.innerHTML = issuesHTML;
} // ← closes `if (issuesCell)`
// ✅ Risk Summary block — INSIDE the function, BEFORE closing brace
// Update Risk Summary
const riskSummaryCell = document.getElementById(`readiness-risk-summary-${prId}`); // ← ✅ prId (not pr.id)
if (riskSummaryCell) {
const summary = readiness.risk_summary;
if (summary && summary.trim()) {
const colorClass = readiness.merge_ready
? 'text-emerald-700 dark:text-emerald-400'
: readiness.blockers && readiness.blockers.length > 0
? 'text-red-700 dark:text-red-400'
: 'text-amber-700 dark:text-amber-400';
riskSummaryCell.innerHTML = `
<span class="text-xs ${colorClass}" title="${escapeHtml(summary)}">
${escapeHtml(summary)}
</span>`;
} else {
riskSummaryCell.innerHTML = '<span class="text-xs text-slate-400">-</span>';
}
}
} // ← updateInlineCells closes HERESummary of both fixes:
|
Closes #185
Introduce an optional AI-based summary generator that:
Takes existing deterministic rule outputs as input
Produces a short, professional risk narrative
Does not replace or alter core rule logic
Includes deterministic fallback if AI fails
Summary by CodeRabbit