Skip to content

Validate listType usage on struct fields#569

Draft
lalitc375 wants to merge 1 commit intokubernetes:masterfrom
lalitc375:list-type-usage
Draft

Validate listType usage on struct fields#569
lalitc375 wants to merge 1 commit intokubernetes:masterfrom
lalitc375:list-type-usage

Conversation

@lalitc375
Copy link
Copy Markdown

Validate listType usage on struct fields

Fixes : #554.

kube-openapi is updated to validate the usage of the // +listType marker. The tool will now generate an error if this marker is applied to any field that is not a slice or an array. This change ensures that the OpenAPI specifications for core Kubernetes types are generated with the same strictness as those for CRDs, preventing downstream tooling failures.

Problem:

Currently, kube-openapi allows the // +listType marker to be used on fields that are not lists or slices. This can result in the generation of an invalid OpenAPI schema. For example, a +listType=atomic marker was incorrectly applied to the metav1.Status.Details field, which is a struct, not a list type. This causes tools that consume the schema, such as controller-gen, to fail when generating Custom Resource Definitions (CRDs) that embed metav1.Status.

Solution:

This pull request introduces a validation check in kube-openapi to ensure that the +listType marker is only used on slice or array fields. If the marker is used on any other type of field, an error will be returned.

Unit tests have been added to verify the new validation logic, including a test case that is expected to fail when +listType is used on a string field.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lalitc375
Once this PR has been reviewed and has the lgtm label, please assign jefftree 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 the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 5, 2025
@k8s-ci-robot k8s-ci-robot requested review from jpbetz and sttts December 5, 2025 18:09
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 5, 2025
@lalitc375 lalitc375 marked this pull request as draft December 8, 2025 17:52
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 8, 2025
@k8s-triage-robot
Copy link
Copy Markdown

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 8, 2026
@k8s-triage-robot
Copy link
Copy Markdown

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. 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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align kube-openapi validation with controller-gen for +listType marker

3 participants