Skip to content

Panic in graph builder causes controller crash on unexpected CRD configuration #900

@AnshulPatil2005

Description

@AnshulPatil2005

Description

Description
The graph builder uses panic() instead of proper error handling when encountering unexpected CRD configurations, which can crash the entire kro controller process in production.
Problem

panic() halts the entire controller, causing service downtime, poor UX, and loss of all active reconciliations.

Current Code
if len(crdCopy.Spec.Versions) != 1 || crdCopy.Spec.Versions[0].Schema == nil {
panic("Expected CRD to have exactly one version with schema defined")
}

Proposed Fix

Replace panic() with proper error handling:

if len(crdCopy.Spec.Versions) != 1 {
return nil, fmt.Errorf("expected one version, got %d", len(crdCopy.Spec.Versions))
}
if crdCopy.Spec.Versions[0].Schema == nil {
return nil, fmt.Errorf("schema is nil in version 0")
}

Benefits

Prevents full controller crash
Provides clear error messages

Which option describes the most your issue?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions