Skip to content

fix(cronjob): handle undefined spec.suspend in List and Details#5085

Open
Athang69 wants to merge 1 commit intokubernetes-sigs:mainfrom
Athang69:fix/cronjob-spec-suspend-undefined
Open

fix(cronjob): handle undefined spec.suspend in List and Details#5085
Athang69 wants to merge 1 commit intokubernetes-sigs:mainfrom
Athang69:fix/cronjob-spec-suspend-undefined

Conversation

@Athang69
Copy link
Copy Markdown
Contributor

@Athang69 Athang69 commented Apr 7, 2026

Summary

This PR fixes a crash in the CronJob list and details pages when spec.suspend is not explicitly set in the CronJob manifest. Kubernetes defaults spec.suspend to false but does not always include it in the API response, causing .toString() to be called on undefined and throwing a TypeError

Related Issue

Fixes #5083

Changes

  • Fixed frontend/src/components/cronjob/List.tsx added ?? false fallback before .toString() on spec.suspend in the Suspend column getValue
  • Fixed frontend/src/components/cronjob/Details.tsx added ?. optional chaining on spec and ?? false fallback for isCronSuspended derivation
  • Fixed frontend/src/components/cronjob/Details.tsx added ?? false fallback before .toString() on spec.suspend in the extraInfo Suspend field

Steps to Test

  1. Apply a CronJob manifest that omits spec.suspend e.g. a Helm generated CronJob
  2. Navigate to Workloads -> CronJobs
  3. Verify the list renders correctly and shows false in the Suspend column without crashing
  4. Click on the CronJob to open its details page
  5. Verify the details page renders correctly and shows false for the Suspend field
  6. Repeat with a CronJob that has spec.suspend:true explicitly set and verify it still shows true correctly

Notes for the Reviewer

spec.suspend is defined as optional in the Kubernetes batch/v1 CronJobSpec its absence from the API response is valid behaviour, not a bug in the cluster
The ?? false fallback exactly matches the Kubernetes-defined default for this field, so there is no behaviour change for CronJobs that have the field explicitly set
The additional ?. on spec in isCronSuspended guards against the loading phase before the API response arrives, which the original cronJob?.spec.suspend did not cover

@k8s-ci-robot k8s-ci-robot requested review from ashu8912 and skoeva April 7, 2026 18:02
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Athang69
Once this PR has been reviewed and has the lgtm label, please assign illume 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

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CronJob details and list crash when spec.suspend is not set (undefined)

2 participants