fix: generate issue summaries after save - #5568
Tanishq-mellu wants to merge 2 commits into
Conversation
|
Warning Review limit reachedNext included review available in 20 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. Summary by CodeRabbit
WalkthroughThe issue model now uses the issue body when AI summary generation returns no content. It saves open issues before generating summaries, then persists the summary with a second save. Tests cover both behaviors. ChangesIssue summary persistence
Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to New issue summaries are generated after the issue is saved, but the follow-up summary save may not use the same database as the initial save. In deployments using non-default database aliases, cards could still lack persisted summaries; routing should be corrected before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
7212928 to
afd78b7
Compare
|
Contribution validation failed:
|
Signed-off-by: Tanishq-mellu <tnshqmeshram@gmail.com>
afd78b7 to
6465cd2
Compare
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Confidence score: 4/5
backend/src/apps/github/models/issue.pystill generates and saves a summary when callers intentionally use Django’s validsave(update_fields=[])no-op, causing unexpected work and persistence changes; return early for an emptyupdate_fieldsbefore hint generation or the first save.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/src/apps/github/models/issue.py">
<violation number="1" location="backend/src/apps/github/models/issue.py:192">
P2: When callers use Django’s valid `save(update_fields=[])` no-op, this branch still generates and saves a summary. Return immediately for an empty `update_fields` before running hint generation or the first save.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| if not self.summary: | ||
| self.generate_summary() | ||
| if self.is_open and not self.hint: |
There was a problem hiding this comment.
P2: When callers use Django’s valid save(update_fields=[]) no-op, this branch still generates and saves a summary. Return immediately for an empty update_fields before running hint generation or the first save.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/src/apps/github/models/issue.py, line 192:
<comment>When callers use Django’s valid `save(update_fields=[])` no-op, this branch still generates and saves a summary. Return immediately for an empty `update_fields` before running hint generation or the first save.</comment>
<file context>
@@ -185,19 +185,19 @@ def generate_summary(self, open_ai: OpenAi | None = None, max_tokens: int = 500)
-
- if not self.summary:
- self.generate_summary()
+ if self.is_open and not self.hint:
+ self.generate_hint()
</file context>
| if self.is_open and not self.hint: | |
| if "update_fields" in kwargs and not kwargs["update_fields"]: | |
| return | |
| if self.is_open and not self.hint: |
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
|
Contribution validation failed:
|
1 similar comment
|
Contribution validation failed:
|
|
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic



Summary
Fixes #5506
Fixes AI-generated issue summaries for newly created GitHub issues.
Root Cause
Issue.save()previously attempted to generate the AI summary before the issue was persisted.For a newly created issue,
self.idwas stillNone. Sincegenerate_summary()checksis_indexable, andis_indexablerequires the issue to have an ID, summary generation returned early.As a result, newly created issues could be saved without an AI-generated summary.
Changes
Testing
Targeted unit tests
poetry run pytest tests/unit/apps/github/models/issue_test.py -q
--cov=apps.github.models.issue
--cov-report=term-missing
--cov-fail-under=0
20 passed
apps/github/models/issue.py: 100% coverage
Additional validation
git diff --check