Skip to content

Conversation

@saschagrunert
Copy link
Member

The linter was incorrectly skipping JSON tag validation for list types (structs with TypeMeta, ListMeta, and Items fields). This allowed list types with missing or incorrect JSON tags to pass validation, which could cause serialization/deserialization issues.

Fixes #147

@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 Oct 30, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: saschagrunert
Once this PR has been reviewed and has the lgtm label, please assign jpbetz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

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 requested a review from sivchari October 30, 2025 08:10
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 30, 2025
The linter was incorrectly skipping JSON tag validation for list types
(structs with TypeMeta, ListMeta, and Items fields). This allowed list
types with missing or incorrect JSON tags to pass validation, which
could cause serialization/deserialization issues.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
@saschagrunert saschagrunert force-pushed the fix-issue-147-list-types-linting branch from 896a0d7 to 7b5248f Compare October 30, 2025 08:15
@saschagrunert saschagrunert marked this pull request as ready for review October 30, 2025 08:20
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 30, 2025
Copy link
Member

@sivchari sivchari left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 30, 2025
// inspectFieldsIncludingListTypes iterates over fields in structs, including list types.
// This is a custom implementation that bypasses the inspector's InspectFields helper
// to ensure list types are also linted for proper JSON tags.
func (a *analyzer) inspectFieldsIncludingListTypes(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we will iterate over all the fields we iterated on in the normal inspector again by doing this, is that right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, one alternative was to change the normal inspector, but that would affect all linters, which is why I decided to keep the change scoped to jsontags.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess if we are iterating again, we may as well just skip the first pass no?

Copy link
Contributor

Choose a reason for hiding this comment

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

The alternative is to somehow have options to how the inspector iterates (maybe adding a CheckFieldsIncludingListTypes) and using that here instead? Then internally there can be some sharing?

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAL skips List tags linting

4 participants