Skip to content

fix(generic-specializer): prevent panic on missing kptfile status#1100

Open
pulkitvats2007-crypto wants to merge 1 commit into
nephio-project:mainfrom
pulkitvats2007-crypto:fix-nil-kptfile-status
Open

fix(generic-specializer): prevent panic on missing kptfile status#1100
pulkitvats2007-crypto wants to merge 1 commit into
nephio-project:mainfrom
pulkitvats2007-crypto:fix-nil-kptfile-status

Conversation

@pulkitvats2007-crypto
Copy link
Copy Markdown
Contributor

Summary

The generic-specializer was crashing when processing Kptfiles that do not contain a status block.
This PR adds a defensive nil check to safely handle such cases and allow reconciliation to continue.


Root Cause

kptfile.Status is an optional pointer.
The controller assumed it is always present and directly accessed:

kptfile.Status.Conditions

When Status == nil, this caused a runtime panic:
invalid memory address or nil pointer dereference.

In Go, dereferencing a nil pointer always results in a runtime panic if not checked beforehand, because the pointer does not reference any valid memory location oai_citation:0‡codegenes.


Fix

Added a nil check before accessing Status.Conditions:

if kptfile.Status != nil {
    // safely process conditions
}

Testing

  • Added unit test: reconciler_nil_status_test.go
  • Validates that reconciliation succeeds with a status-less Kptfile
  • Confirms no panic occurs

Impact

  • Prevents controller crashes during reconciliation
  • Unblocks PackageRevisions created from fresh or manually authored packages
  • Eliminates silent failure loops and stuck resources
  • Improves overall reliability of the generic-specializer in production

…status

Signed-off-by: pulkitvats2007-crypto <pulkitvats2007@gmail.com>
@nephio-prow
Copy link
Copy Markdown
Contributor

nephio-prow Bot commented Apr 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign liamfallon for approval by writing /assign @liamfallon in a comment. For more information see the Kubernetes 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

@nephio-prow
Copy link
Copy Markdown
Contributor

nephio-prow Bot commented Apr 20, 2026

Hi @pulkitvats2007-crypto. Thanks for your PR.

I'm waiting for a nephio-project member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant