Skip to content

refactor: add new lint for omitempty on slice fields and apply it treewide #980

Draft
christian-heusel wants to merge 2 commits intokubeflow:notebooks-v2from
christian-heusel:feat/build-go-lint-tool-omitempty
Draft

refactor: add new lint for omitempty on slice fields and apply it treewide #980
christian-heusel wants to merge 2 commits intokubeflow:notebooks-v2from
christian-heusel:feat/build-go-lint-tool-omitempty

Conversation

@christian-heusel
Copy link

@christian-heusel christian-heusel commented Mar 19, 2026

  • feat: add jsonomitemptylint custom linter for Go slice fields
  • fix: Add omitempty to slice fields in Go types

The idea on this was brought up by @thesuperzapper regarding the discussion around #976.

Alternatively we could aim to use the nil as empty array change from the upcoming from the jsonv2 proposal in golang:

A nil Go slice is marshaled as an empty JSON array (more discussion).

golang/go#63397 / https://pkg.go.dev/encoding/json/v2


This will most likely break the frontend and require adjustments in the tests, so this is not to be merged yet.

Would be nice to get some intput on this from @ederign for the frontend side of things as per @andyatmiami's tip.

Adds a standalone go/analysis linter (tools/linters) that enforces
omitempty on all slice fields with a json struct tag. Integrates it
into the lint target of both the backend and controller Makefiles.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Christian Heusel <christian@heusel.eu>
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kimwnasptd for approval. For more information see the Kubernetes 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

@google-oss-prow google-oss-prow bot added area/controller area - related to controller components area/v2 area - version - kubeflow notebooks v2 size/L labels Mar 19, 2026
Fixes all violations reported by the new linter, adding the omitempty
tag to slice fields across all backend models and controller API types.

Signed-off-by: Christian Heusel <christian@heusel.eu>
@christian-heusel christian-heusel force-pushed the feat/build-go-lint-tool-omitempty branch from ab11414 to 649028b Compare March 19, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/backend area - related to backend components area/controller area - related to controller components area/v2 area - version - kubeflow notebooks v2 do-not-merge/work-in-progress size/L

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant