Skip to content

Fix nil pointer panic in Jira issue printing#902

Open
nephomaniac wants to merge 2 commits into
openshift:masterfrom
nephomaniac:fix-jira-nil-panic
Open

Fix nil pointer panic in Jira issue printing#902
nephomaniac wants to merge 2 commits into
openshift:masterfrom
nephomaniac:fix-jira-nil-panic

Conversation

@nephomaniac
Copy link
Copy Markdown
Contributor

@nephomaniac nephomaniac commented May 23, 2026

Summary

  • Fix nil pointer dereference in PrintJiraIssues (pkg/utils/print.go) when a Jira issue has nil Priority or Status fields
  • Fix same issue in printJIRASupportExceptions (cmd/cluster/context.go)

Root Cause

i.Fields.Priority and i.Fields.Status are 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

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x20 pc=0x1044d647c]

goroutine 1 [running]:
github.com/openshift/osdctl/pkg/utils.PrintJiraIssues({0x65274b7054a0, 0x3, 0x0?})
    github.com/openshift/osdctl/pkg/utils/print.go:94 +0x12c
github.com/openshift/osdctl/cmd/cluster.(*contextOptions).printLongOutput(...)
    github.com/openshift/osdctl/cmd/cluster/context.go:260 +0x1c8
github.com/openshift/osdctl/cmd/cluster.(*contextOptions).run(...)
    github.com/openshift/osdctl/cmd/cluster/context.go:240 +0x1ec

Test plan

  • osdctl cluster context with a cluster that has OHSS issues with nil Priority/Status fields
  • Verify no panic, fields display as "Unknown" instead

/tide squash

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where Jira issue display would fail when certain fields (type, priority, or status) were missing or unavailable. Missing fields now display as "Unknown" instead of causing errors.

@openshift-ci openshift-ci Bot requested review from MateSaary and iamkirkbater May 23, 2026 22:33
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 23, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nephomaniac
Once this PR has been reviewed and has the lgtm label, please assign nikokolas3270 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Warning

Review limit reached

@nephomaniac, we couldn't start this review because you've used your available PR reviews for now.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0a6fe2b4-89d8-4a50-9e9e-be2fb442f197

📥 Commits

Reviewing files that changed from the base of the PR and between c0fc6a5 and 5fb04a3.

📒 Files selected for processing (2)
  • cmd/cluster/context.go
  • pkg/utils/print.go

Walkthrough

Jira issue printing functions in two files add defensive nil checks for Type, Priority, and Status fields, defaulting to "Unknown" when unavailable, replacing direct dereferences that could cause nil pointer panics.

Changes

Defensive Jira Field Handling

Layer / File(s) Summary
Defensive nil checks in Jira printing functions
cmd/cluster/context.go, pkg/utils/print.go
printJIRASupportExceptions and PrintJiraIssues now compute typeName, priorityName, and statusName with nil checks, defaulting to "Unknown" when Jira fields are missing, instead of directly dereferencing potentially nil fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Fix nil pointer panic in Jira issue printing' directly and clearly describes the main change: preventing nil pointer panics when printing Jira issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PR modifies only utility functions for Jira issue printing. No test files modified and no Ginkgo tests (It(), Describe(), etc.) present in changed code.
Test Structure And Quality ✅ Passed Custom check for Ginkgo test code is not applicable. This PR adds only standard Go tests using testing.T and testify/assert, not Ginkgo. No Describe/Context/It/BeforeEach patterns found.
Microshift Test Compatibility ✅ Passed This PR modifies utility functions to fix nil pointer panics in Jira issue handling, not e2e tests. The MicroShift compatibility check only applies to new Ginkgo e2e tests, which this PR does not add.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR fixes nil pointer handling in Jira issue printing utilities. No Ginkgo e2e tests are added; custom check for SNO test compatibility is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only Jira issue printing utility functions with no Kubernetes scheduling constraints, deployment manifests, or topology-dependent configuration. Not applicable to check.
Ote Binary Stdout Contract ✅ Passed osdctl is not an OTE binary but a standalone CLI tool, making the OTE Binary Stdout Contract check inapplicable. The PR only adds nil checks without introducing new stdout writes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests are added in this PR; it only modifies utility functions in cmd/cluster/context.go and pkg/utils/print.go for safer Jira issue printing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b9103f and c0fc6a5.

📒 Files selected for processing (2)
  • cmd/cluster/context.go
  • pkg/utils/print.go

Comment thread cmd/cluster/context.go
Comment thread pkg/utils/print.go Outdated
@nephomaniac nephomaniac force-pushed the fix-jira-nil-panic branch from c0fc6a5 to 5fb04a3 Compare May 23, 2026 23:20
@nephomaniac
Copy link
Copy Markdown
Contributor Author

/label tide/merge-method-squash

@openshift-ci openshift-ci Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 23, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 24, 2026

@nephomaniac: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant