Fix nil pointer panic in Jira issue printing#902
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nephomaniac The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 13 minutes and 10 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
WalkthroughJira issue printing functions in two files add defensive nil checks for Type, Priority, and Status fields, defaulting to ChangesDefensive Jira Field Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 11 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (11 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@cmd/cluster/context.go`:
- Around line 809-822: The code dereferences i.Fields (e.g., i.Fields.Type.Name,
i.Fields.Priority, i.Fields.Status, i.Fields.Summary) without guarding that
i.Fields can be nil; update the block that builds typeName, priorityName,
statusName and prints the issue to first check if i.Fields == nil and if so use
safe defaults ("Unknown" for names and an empty summary) before accessing
i.Fields.Type, i.Fields.Priority, i.Fields.Status, and i.Fields.Summary,
ensuring all fmt.Fprintf calls use those guarded values (referencing the same i
variable and JiraBaseURL) to avoid nil-pointer panics.
In `@pkg/utils/print.go`:
- Around line 94-107: PrintJiraIssues (and similarly printJIRASupportExceptions)
currently dereferences i.Fields (accessing i.Fields.Type, i.Fields.Priority,
i.Fields.Status, i.Fields.Summary, i.Fields.Created) without checking for nil
which can panic; update both functions to first check if i.Fields == nil and if
so set local defaults (e.g., typeName, priorityName, statusName, summary,
createdTime) before accessing subfields, otherwise read values from i.Fields as
before, and use those locals in the fmt.Printf calls so no dereference occurs
when Fields is nil.
🪄 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: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: d71bfa26-230c-402b-ad59-829941bdbe41
📒 Files selected for processing (2)
cmd/cluster/context.gopkg/utils/print.go
c0fc6a5 to
5fb04a3
Compare
|
/label tide/merge-method-squash |
|
@nephomaniac: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
PrintJiraIssues(pkg/utils/print.go) when a Jira issue has nilPriorityorStatusfieldsprintJIRASupportExceptions(cmd/cluster/context.go)Root Cause
i.Fields.Priorityandi.Fields.Statusare pointer types in the go-jira library and can be nil when the Jira issue doesn't have those fields set. The code dereferenced them without nil checks.Stack Trace
Test plan
osdctl cluster contextwith a cluster that has OHSS issues with nil Priority/Status fields/tide squash
🤖 Generated with Claude Code
Summary by CodeRabbit