mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2026-07-17 18:30:21 +00:00
The Deployment analyzer dereferenced *deployment.Spec.Replicas without a nil check. Spec.Replicas is a *int32 and, although the API server usually defaults it to 1, a Deployment object whose replicas field is explicitly unset (nil) panics the analyze run with a nil pointer dereference. Guard the comparison with a nil check, mirroring the sibling StatefulSet analyzer which already checks Spec.Replicas != nil before dereferencing. Add a regression test that analyzes a Deployment with nil Spec.Replicas and asserts Analyze does not panic. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>