Skip to content

generic-specializer: skip condition walk when Kptfile.Status is nil#1105

Open
SAY-5 wants to merge 1 commit into
nephio-project:mainfrom
SAY-5:fix/generic-specializer-nil-kptfile-status-1099
Open

generic-specializer: skip condition walk when Kptfile.Status is nil#1105
SAY-5 wants to merge 1 commit into
nephio-project:mainfrom
SAY-5:fix/generic-specializer-nil-kptfile-status-1099

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 20, 2026

Summary

kptv1.KptFile.Status is defined as *Status (optional), so newly cloned repos, raw drafts, and hand-authored packages reach the generic-specializer reconciler with Status == nil. The reconciler ranged over kptfile.Status.Conditions and then called porchcondition.GetPorchConditions(kptfile.Status.Conditions) without checking, so these common shapes panicked and permanently stalled the PackageRevision lifecycle (#1099).

Fixes kptdev/porch#909.

Change

controllers/pkg/reconcilers/generic-specializer/reconciler.go, wrap the condition walk + readiness-gate check in if kptfile.Status != nil { ... }. A Kptfile with no status has no conditions to walk anyway, so the ready-gate check on this path is trivially false in that case.

Testing

  • go build ./controllers/... passes.
  • Manual: fed the reconciler a PackageRevision whose Kptfile has no status block. Previously it panicked inside the generic-specializer goroutine; now it logs nothing and moves on, and subsequent revisions for the same package progress normally.

kptv1.KptFile.Status is an optional *Status, so newly cloned repos,
raw drafts, and hand-authored packages reach the reconciler with
Status == nil. The reconciler ranged over
kptfile.Status.Conditions and then called
porchcondition.GetPorchConditions(kptfile.Status.Conditions) without
checking, which panicked and stalled the PackageRevision lifecycle
(#1099).

Guard the whole block with `if kptfile.Status != nil`. A Kptfile
with no status has no conditions to walk anyway, so the ready-gate
check on this path is trivially false in that case.

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>

Fixes #1099
@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 johnbelamaric for approval by writing /assign @johnbelamaric 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 nephio-prow Bot requested review from efiacor and liamfallon April 20, 2026 22:27
@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

@nephio-prow
Copy link
Copy Markdown
Contributor

nephio-prow Bot commented Apr 20, 2026

Hi @SAY-5. 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.

strings.HasPrefix(c.Type, kptfilelibv1.GetConditionType(&ipamFor)+".") ||
strings.HasPrefix(c.Type, kptfilelibv1.GetConditionType(&configInjectFor)+".") {
log.Info("generic specializer conditions", "packageName", pr.Spec.PackageName, "repository", pr.Spec.RepositoryName, "status", c.Status, "condition", c.Type, "message", c.Message)
// kptv1.KptFile.Status is an optional *Status; newly
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can KptFile.Status ever be nil?

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.

Nil Pointer Dereference in Generic Specializer when Processing Kptfile without Status

2 participants