Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: cmd/vet: warn about structs marked json omitempty #51261

Open
josharian opened this issue Feb 18, 2022 · 33 comments
Open

proposal: cmd/vet: warn about structs marked json omitempty #51261

josharian opened this issue Feb 18, 2022 · 33 comments
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Proposal
Milestone

Comments

@josharian
Copy link
Contributor

Marking a struct field of type time.Time as json omitempty has no effect. You must use a *time.Time for it to work (which is wire compatible). Vet should detect this situation and perhaps suggest *time.Time instead.

This might be reasonably extended to any struct type; see the linked omitzero proposals for more discussion. If an omitzero proposal is accepted, vet could switch to suggesting the use of omitzero rather than suggesting a pointer type.

cc @dsnet @robpike @dominikh

@dsnet
Copy link
Member

dsnet commented Feb 18, 2022

Scanning all modules, I found ~73k fields where the type was either time.Time or *time.Time with a json:omitempty tag. Approximately 33% were of the former (incorrect) and 66% were of the latter (correct) form.

That's pretty significant evidence that this is a highly frequent problem.

@dominikh
Copy link
Member

Is there any reason to limit this to time.Time instead of applying to all structs?

@dsnet
Copy link
Member

dsnet commented Feb 19, 2022

I advocate expanding it to all structs.

@guodongli-google
Copy link

Yes this shall be extending any non-primitive and non-reference types, mainly struct.

Interestingly, the official document specifies:

Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type time.Time, not *time.Time.

which actually indicates that a conflicting check that is supposed to report usage of *time.Time in struct fields.
For any time.Time fields, omitempty has no effects. What other harm it can bring other than wasting some storage?

@prattmic
Copy link
Member

I don't write much JSON code, so take my thoughts with a grain of salt, but this problem seems to indicate that there should be some form of json:omitzero to omit fields that are equal to the type's zero value [1]. It seems rather painful to require use of pointers just to allow omission on the wire.

[1] Admittedly this is still a problem for time.Time, which prefers time.Time.IsZero() over comparison with var zero time.Time.

@dsnet
Copy link
Member

dsnet commented Feb 22, 2022

this problem seems to indicate that there should be some form of json:omitzero to omit fields that are equal to the type's zero value

I agree there should be some type of omitzero tag that does what the user intends here, but that seems orthogonal to a vet warning that flags incorrect usages of omitempty with a Go struct type.

@guodongli-google
Copy link

this problem seems to indicate that there should be some form of json:omitzero to omit fields that are equal to the type's zero value

I agree there should be some type of omitzero tag that does what the user intends here, but that seems orthogonal to a vet warning that flags incorrect usages of omitempty with a Go struct type.

It is a little bit confusing what "empty" means. Currently:

The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.

Regarding a composite object, what does "empty" or "zero" mean? Consider these cases:

  1. type T struct {}; var o T: obviously o is an empty object.
  2. type T struct { x int; y *int }; var o T;: o is not empty but it is zero.
  3. type T struct { x int}; o := map[int]T{0: T{}};: o is not empty but is it zero?

Users seems to assume that (2) is "empty" when using "omitempty".

@dsnet
Copy link
Member

dsnet commented Feb 22, 2022

I think this issue getting off topic. There's a lot of valid questions with regard to omitzero, omitempty, and their exact semantics, but that discussion belongs in #11939. We should separate "how can json make this better in the future" from "how can we detect incorrect usages today".

@timothy-king
Copy link
Contributor

One concern I have is how to educate users. It seems like the most likely cause is the user misunderstanding of how structs interact with encoding/json with omitempty being a symptom. Vet's message have historically been quite terse. I am hesitant to give suggestions like "rewrite time.Time to *time.Time here" without giving an explanation as to why (and can cause other bugs during the transition). Similarly a message like "struct field %s is not emitted by encoding/json so the omitempty tag is redundant" seems like it would often [usually?] result in the omitempty tag being removed which does not help the underlying confusion.

Do folks have a suggestion for what to tell the user in the diagnostic? What I really want to do is point users at a longer discussion of the issue (like 1-2 paragraphs describing the issue and possible solutions), but to the best of my knowledge this has not done this before in vet.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/388574 mentions this issue: go/analysis/passes/structtag: check option "omitempty" on fields of struct types.

@andig
Copy link
Contributor

andig commented Oct 14, 2023

I think this issue getting off topic
Is there any reason to limit this to time.Time instead of applying to all structs?

I've proposed an implementation for vetting on omitempty in the general case where this is currently a no-op: #63541

We should separate "how can json make this better in the future" from "how can we detect incorrect usages today".

If this issue needs more consideration I'd appreciate if we could reopen #63539 with it's narrower focus.

andig added a commit to andig/go that referenced this issue Oct 14, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/535416 mentions this issue: cmd/go: add vet check for json/xml omitempty struct tags on non-basic types

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/535515 mentions this issue: cmd/go: add vet check for json/xml omitempty struct tags on non-basic types

andig added a commit to andig/go-tools that referenced this issue Oct 16, 2023
… types

Fixes golang/go#51261

Change-Id: Ic71f614acd3a78a9db73483ccefe613cb7f66e5d
andig added a commit to andig/go-tools that referenced this issue Oct 16, 2023
… types

Fixes golang/go#51261

Change-Id: I99c3a0afc5171777b39f8288e2159f8554151e43
@mvdan
Copy link
Member

mvdan commented Jan 10, 2024

I ran face first into this very bug in the x/oauth2 package: https://pkg.go.dev/golang.org/x/oauth2#Token

@mvdan
Copy link
Member

mvdan commented Jan 17, 2024

@rakyll @shinfan @codyoss per https://dev.golang.org/owners - would it be OK to send a patch to make oauth2.Token.Expiry a pointer per the above? It's a v0, so I assume such a breaking change to un-break omitempty would be okay. The alternative would be to wait for encoding/json/v2, which will support this without a pointer, and which is perhaps the best end state in the long run - but we're also blocked for a while.

@codyoss
Copy link
Member

codyoss commented Jan 17, 2024

@mvdan I think even though it is v0 The whole TokenSource interface is quite pervasive in the oauth space. I think we should not make a breaking change here. With how this struct is used I don't think data is actually serialized all that much -- it is much more common to deserialize into it. Does that seem worth the ripple effects imo.

@thw0rted
Copy link

I advocate expanding it to all structs.

Has this issue been expanded to include flagging any inline-struct field that is (uselessly) tagged omitempty? If so, can the title be updated to reflect that? (cc @josharian) If not, should we file a new, broader issue?

We just fixed a bug that bit us in production because our product spent years making API calls, sending JSON that included an extra property with a {} value, and the receiving service finally added data validation that rejected it. We never knew that omitempty on an inline-struct member does nothing, until now....

@andig
Copy link
Contributor

andig commented Feb 12, 2024

@mvdan you're not the first one ;) I'm absolutely puzzled why it seems so hard to move this issue forward?

@timothy-king
Copy link
Contributor

timothy-king commented May 7, 2024

I ran a candidate implementation on a large selection of Go packages with >=10 imports.

I looked at an earlier sample and all of the reports looked accurate. We may want to treat generated code specially though. The candidate implementation is now gated to only warn when it knows that ast.IsGenerated is false. The reports in hand written code all look like warnings someone should fix. The diagnostics in generated code are correct, but I am less confident users will want to take action by changing the generated code. That code might be written over or the generator is hard to fix, etc. The fix is to change the generator, which is a bit of a slower process and not very CICD friendly. Hence the additional IsGenerated requirement in the prototype I added.

Examples this would exclude: 1, 2. Some diagnostics are in generated code that do not yet satisfy IsGenerated (example), but we do need to pick some standard and that is ast.IsGenerated.

I think it would be okay to release the omitempty check in go version N, and remove the IsGenerated check in go version N+1. So I don't think this has to be a requirement forever.

Here are 100 randomly selected diagnostics out of 29697 (no ast.IsGenerated files):
https://go-mod-viewer.appspot.com/github.com/apache/camel-k/pkg/apis/camel@v1.12.1/v1/build_types.go#L236: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/khulnasoft-lab/tunnel-db@v0.0.0-20231117205118-74e1113bd007/pkg/vulnsrc/oracle-oval/types.go#L13: field IssuedDate has omitempty tag which has no effect on struct type github.com/khulnasoft-lab/tunnel-db/pkg/vulnsrc/oracle-oval.Date
https://go-mod-viewer.appspot.com/github.com/Azure/aad-pod-identity@v1.8.17/pkg/apis/aadpodidentity/v1/types.go#L129: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cce/v3/clusters/results.go#L67: field Authentication has omitempty tag which has no effect on struct type github.com/chnsz/golangsdk/openstack/cce/v3/clusters.AuthenticationSpec
https://go-mod-viewer.appspot.com/github.com/hscells/guru@v0.0.0-20200207042420-2dabeb950d69/medgen.go#L18: field XMLName has omitempty tag which has no effect on struct type encoding/xml.Name
https://go-mod-viewer.appspot.com/github.com/percona/percona-xtradb-cluster-operator@v1.14.0/pkg/apis/pxc/v1/pxc_types.go#L555: field Resources has omitempty tag which has no effect on struct type k8s.io/api/core/v1.ResourceRequirements
https://go-mod-viewer.appspot.com/github.com/pingcap/tidb-operator/pkg/apis@v1.5.3/pingcap/v1alpha1/tidbngmonitoring_types.go#L93: field NGMonitoring has omitempty tag which has no effect on struct type github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.NGMonitoringStatus
https://go-mod-viewer.appspot.com/github.com/plutov/paypal/v4@v4.7.1/types.go#L271: field PartialPayment has omitempty tag which has no effect on struct type github.com/plutov/paypal/v4.InvoicePartialPayment
https://go-mod-viewer.appspot.com/github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/apis/ca/v1/ca.go#L157: field FileKeyStore has omitempty tag which has no effect on struct type github.com/IBM-Blockchain/fabric-operator/pkg/apis/ca/v1.FileKeyStoreOpts
https://go-mod-viewer.appspot.com/k8s.io/kube-openapi@v0.0.0-20240430033511-f0e62f92d13f/pkg/internal/third_party/go-json-experiment/json/testdata_test.go#L508: field Entities has omitempty tag which has no effect on struct type k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json.twitterEntities
https://go-mod-viewer.appspot.com/github.com/minio/madmin-go@v1.7.5/cluster-commands.go#L464: field SSEConfigUpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/giantswarm/apiextensions/v2@v2.6.2/pkg/apis/infrastructure/v1alpha2/g8s_control_plane_types.go#L51: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/minio/madmin-go/v3@v3.0.51/perf-object.go#L45: field TTFB has omitempty tag which has no effect on struct type github.com/minio/madmin-go/v3.Timings
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L6203: field ServiceLevel has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.ServiceLevelDefinition
https://go-mod-viewer.appspot.com/github.com/goreleaser/goreleaser@v1.25.1/pkg/config/config.go#L263: field Repository has omitempty tag which has no effect on struct type github.com/goreleaser/goreleaser/pkg/config.RepoRef
https://go-mod-viewer.appspot.com/libvirt.org/go/libvirtxml@v1.10003.0/nwfilter.go#L114: field DstIPTo has omitempty tag which has no effect on struct type libvirt.org/go/libvirtxml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/argoproj-labs/argocd-operator@v0.10.0/api/v1alpha1/argocd_types.go#L518: field Autoscale has omitempty tag which has no effect on struct type github.com/argoproj-labs/argocd-operator/api/v1alpha1.ArgoCDServerAutoscaleSpec
https://go-mod-viewer.appspot.com/halkyon.io/api@v1.0.0-rc.6/component/v1beta1/types.go#L193: field Spec has omitempty tag which has no effect on struct type halkyon.io/api/component/v1beta1.ComponentSpec
https://go-mod-viewer.appspot.com/github.com/amimof/huego@v1.2.1/capabilities.go#L6: field Lights has omitempty tag which has no effect on struct type github.com/amimof/huego.Capability
https://go-mod-viewer.appspot.com/github.com/charmbracelet/glamour@v0.7.0/ansi/style.go#L102: field List has omitempty tag which has no effect on struct type github.com/charmbracelet/glamour/ansi.StyleList
https://go-mod-viewer.appspot.com/github.com/saferwall/pe@v1.5.2/file.go#L17: field DOSHeader has omitempty tag which has no effect on struct type github.com/saferwall/pe.ImageDOSHeader
https://go-mod-viewer.appspot.com/github.com/kuadrant/authorino@v0.17.2/api/v1beta2/auth_config_types.go#L618: field SubResource has omitempty tag which has no effect on struct type github.com/kuadrant/authorino/api/v1beta2.ValueOrSelector
https://go-mod-viewer.appspot.com/github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.1.0/pkg/appsec/tuning_recommendations.go#L62: field EvaluationPeriodEnd has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/banzaicloud/istio-operator/pkg/apis@v0.10.8/istio/v1beta1/istio_types.go#L402: field Init has omitempty tag which has no effect on struct type github.com/banzaicloud/istio-operator/pkg/apis/istio/v1beta1.ProxyInitConfiguration
https://go-mod-viewer.appspot.com/github.com/go-playground/webhooks/v6@v6.3.0/github/payload.go#L5664: field Repository has omitempty tag which has no effect on type struct{Name struct{From string "json:"from""} "json:"name""}
https://go-mod-viewer.appspot.com/github.com/twilio/twilio-go@v1.20.1/rest/conversations/v1/model_list_conversation_message_receipt_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/conversations/v1.ListConfigurationAddressResponseMeta
https://go-mod-viewer.appspot.com/github.com/argoproj/argo-events@v1.9.1/pkg/apis/eventbus/v1alpha1/eventbus_types.go#L51: field Config has omitempty tag which has no effect on struct type github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.BusConfig
https://go-mod-viewer.appspot.com/github.com/minio/mc@v0.0.0-20240503112107-b471de8d1882/cmd/health_v1.go#L97: field Info has omitempty tag which has no effect on struct type github.com/minio/madmin-go/v3.InfoMessage
https://go-mod-viewer.appspot.com/github.com/rook/rook/pkg/apis@v0.0.0-20240506202243-c908f01e97b3/ceph.rook.io/v1/types.go#L779: field StatusCheck has omitempty tag which has no effect on struct type github.com/rook/rook/pkg/apis/ceph.rook.io/v1.MirrorHealthCheckSpec
https://go-mod-viewer.appspot.com/github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/icd/icdv4/auto_scaling.go#L25: field Scalers has omitempty tag which has no effect on struct type github.com/IBM-Cloud/bluemix-go/api/icd/icdv4.ScalersBody
https://go-mod-viewer.appspot.com/github.com/blend/go-sdk@v1.20220411.3/web/config.go#L54: field Views has omitempty tag which has no effect on struct type github.com/blend/go-sdk/web.ViewCacheConfig
https://go-mod-viewer.appspot.com/github.com/nats-io/jwt/v2@v2.5.6/decoder_activation.go#L36: field v1NatsActivation has omitempty tag which has no effect on struct type github.com/nats-io/jwt/v2.v1NatsActivation
https://go-mod-viewer.appspot.com/github.com/twilio/twilio-go@v1.20.1/rest/taskrouter/v1/model_list_worker_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/taskrouter/v1.ListActivityResponseMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api@v1.7.1/exp/ipam/api/v1alpha1/ipaddressclaim_types.go#L36: field AddressRef has omitempty tag which has no effect on struct type k8s.io/api/core/v1.LocalObjectReference
https://go-mod-viewer.appspot.com/kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/network/v1alpha1/namespacenetworkpolicy_types.go#L140: field Spec has omitempty tag which has no effect on struct type kubesphere.io/api/network/v1alpha1.NamespaceNetworkPolicySpec
https://go-mod-viewer.appspot.com/github.com/aiven/aiven-go-client@v1.36.0/kafka_topic.go#L48: field MinCompactionLagMs has omitempty tag which has no effect on struct type github.com/aiven/aiven-go-client.KafkaTopicConfigResponseInt
https://go-mod-viewer.appspot.com/github.com/dnsimple/dnsimple-go@v1.7.0/dnsimple/billing.go#L28: field TotalAmount has omitempty tag which has no effect on struct type github.com/shopspring/decimal.Decimal
https://go-mod-viewer.appspot.com/github.com/chaos-mesh/chaos-mesh/api/v1alpha1@v0.0.0-20220226050744-799408773657/workflownode_types.go#L127: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/cidverse/cid-sdk-go@v0.0.0-20240318001225-c193d83f053e/types.go#L126: field Ref has omitempty tag which has no effect on struct type github.com/cidverse/cid-sdk-go.VCSTag
https://go-mod-viewer.appspot.com/github.com/arienmalec/alexa-go@v0.0.0-20181025212142-975687393e90/request.go#L90: field Device has omitempty tag which has no effect on type struct{DeviceID string "json:"deviceId,omitempty""}
https://go-mod-viewer.appspot.com/github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cce/v3/nodepools/requests.go#L172: field Spec has omitempty tag which has no effect on struct type github.com/opentelekomcloud/gophertelekomcloud/openstack/cce/v3/nodepools.UpdateSpec
https://go-mod-viewer.appspot.com/github.com/elastic/gosigar@v0.14.3/cgroup/cpu.go#L16: field CFS has omitempty tag which has no effect on struct type github.com/elastic/gosigar/cgroup.CFS
https://go-mod-viewer.appspot.com/github.com/vmpartner/bitmex@v1.1.0/swagger/instrument.go#L127: field ClosingTimestamp has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/bububa/oceanengine/marketing-api@v0.0.0-20210315120513-0b953137f7a6/model/report/video_frame.go#L15: field EndDate has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/FusionAuth/go-client@v0.0.0-20240425220342-2317e10dfcf5/pkg/fusionauth/Domain.go#L1173: field Email has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.MultiFactorEmailMethod
https://go-mod-viewer.appspot.com/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.73.2/v1/probe_types.go#L36: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/wit-ai/wit-go/v2@v2.0.2/apps.go#L40: field WillTrainAt has omitempty tag which has no effect on struct type github.com/wit-ai/wit-go/v2.Time
https://go-mod-viewer.appspot.com/github.com/rancher/fleet/pkg/apis@v0.9.4/fleet.cattle.io/v1alpha1/cluster_types.go#L159: field Agent has omitempty tag which has no effect on struct type github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1.AgentStatus
https://go-mod-viewer.appspot.com/kubevirt.io/api@v1.2.0/pool/v1alpha1/types.go#L74: field LastProbeTime has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.Time
https://go-mod-viewer.appspot.com/github.com/oam-dev/oam-go-sdk@v0.0.0-20210317082903-d46a6aee5e38/apis/core.oam.dev/v1alpha1/workloadtype_types.go#L73: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/vmware-tanzu/nsx-operator/pkg/apis@v1.0.0/nsx.vmware.com/v1alpha1/subnetset_types.go#L51: field Status has omitempty tag which has no effect on struct type github.com/vmware-tanzu/nsx-operator/pkg/apis/nsx.vmware.com/v1alpha1.SubnetSetStatus
https://go-mod-viewer.appspot.com/github.com/google/go-github/v49@v49.1.0/github/repos_contents.go#L48: field Commit has omitempty tag which has no effect on struct type github.com/google/go-github/v49/git.luolix.topmit
https://go-mod-viewer.appspot.com/github.com/oam-dev/kubevela@v1.9.11/pkg/velaql/providers/query/handler.go#L75: field Filter has omitempty tag which has no effect on struct type github.com/oam-dev/kubevela/pkg/velaql/providers/query.FilterOption
https://go-mod-viewer.appspot.com/github.com/minio/madmin-go/v2@v2.2.1/cluster-commands.go#L482: field TagConfigUpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api@v1.7.1/internal/apis/core/v1alpha4/machineset_types.go#L227: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api@v1.7.1/internal/apis/core/exp/v1alpha3/machinepool_types.go#L224: field Spec has omitempty tag which has no effect on struct type sigs.k8s.io/cluster-api/internal/apis/core/exp/v1alpha3.MachinePoolSpec
https://go-mod-viewer.appspot.com/github.com/gophercloud/gophercloud@v1.11.0/openstack/identity/v3/roles/results.go#L152: field Project has omitempty tag which has no effect on struct type github.com/gophercloud/gophercloud/openstack/identity/v3/roles.Project
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/cloud/types.go#L2405: field Service has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/cloud.CloudService
https://go-mod-viewer.appspot.com/github.com/prebid/prebid-server@v0.275.0/openrtb_ext/floors.go#L92: field Schema has omitempty tag which has no effect on struct type github.com/prebid/prebid-server/openrtb_ext.PriceFloorSchema
https://go-mod-viewer.appspot.com/golift.io/starr@v1.0.0/lidarr/artist.go#L39: field Added has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/oam-dev/kubevela@v1.9.11/pkg/addon/type.go#L69: field Notes has omitempty tag which has no effect on struct type github.com/oam-dev/kubevela/pkg/addon.ElementFile
https://go-mod-viewer.appspot.com/github.com/plutov/paypal/v4@v4.7.1/types.go#L385: field RecipientAddress has omitempty tag which has no effect on struct type github.com/plutov/paypal/v4.InvoiceAddressPortable
https://go-mod-viewer.appspot.com/github.com/goreleaser/goreleaser@v1.25.1/pkg/config/config.go#L907: field Scripts has omitempty tag which has no effect on struct type github.com/goreleaser/goreleaser/pkg/config.NFPMArchLinuxScripts
https://go-mod-viewer.appspot.com/github.com/google/cadvisor@v0.49.1/info/v2/container.go#L89: field Memory has omitempty tag which has no effect on struct type github.com/google/cadvisor/info/v2.MemorySpec
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L3271: field OrderBy has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.AgentTracesTransactionTraceOrderBy
https://go-mod-viewer.appspot.com/github.com/nicolai86/scaleway-sdk@v1.11.1/pkg/api/api.go#L338: field Bootscript has omitempty tag which has no effect on struct type github.com/nicolai86/scaleway-sdk/pkg/api.ScalewayBootscript
https://go-mod-viewer.appspot.com/github.com/libvirt/libvirt-go-xml@v7.4.0+incompatible/nwfilter.go#L136: field ARPDstMACAddr has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/goccy/go-json@v0.10.2/test/cover/cover_marshal_text_test.go#L1791: field A has omitempty tag which has no effect on struct type github.com/goccy/go-json/test/cover_test.coverPtrMarshalText
https://go-mod-viewer.appspot.com/github.com/projectcalico/api@v0.0.0-20231218190037-9183ab93f33e/pkg/apis/projectcalico/v3/bgpfilter.go#L43: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/ferryproxy/api@v0.4.2/apis/traffic/v1alpha2/routepolicy_types.go#L95: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/scaleway/scaleway-cli@v1.11.1/pkg/api/api.go#L302: field Snapshot has omitempty tag which has no effect on struct type github.com/scaleway/scaleway-cli/pkg/api.ScalewaySnapshot
https://go-mod-viewer.appspot.com/github.com/kotalco/kotal@v0.3.0/apis/aptos/v1alpha1/node.go#L60: field Resources has omitempty tag which has no effect on struct type github.com/kotalco/kotal/apis/shared.Resources
https://go-mod-viewer.appspot.com/github.com/kubeshop/testkube@v1.17.23/pkg/imageinspector/types.go#L42: field FetchedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L8248: field Account has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/accounts.AccountReference
https://go-mod-viewer.appspot.com/github.com/muxinc/mux-go@v1.1.1/model_create_track_response.go#L7: field Data has omitempty tag which has no effect on struct type github.com/muxinc/mux-go.Track
https://go-mod-viewer.appspot.com/github.com/snowflakedb/gosnowflake@v1.9.0/query.go#L83: field Creds has omitempty tag which has no effect on struct type github.com/snowflakedb/gosnowflake.execResponseCredentials
https://go-mod-viewer.appspot.com/github.com/OpsMx/go-app-base@v0.0.24/birger/controller.go#L217: field Credential has omitempty tag which has no effect on type struct{Password string "json:"password,omitempty""}
https://go-mod-viewer.appspot.com/github.com/redhat-appstudio/release-service@v0.0.0-20240507045911-a8558ef3422a/api/v1alpha1/release_types.go#L163: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/tada-team/tdproto@v1.51.57/billing_team.go#L8: field DeleteDate has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/greenpau/go-identity@v1.1.6/credit_card.go#L30: field IssuedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/stefanmcshane/helm@v0.0.0-20221213002717-88a4a2c6e77d/pkg/release/info.go#L25: field FirstDeployed has omitempty tag which has no effect on struct type github.com/stefanmcshane/helm/pkg/time.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/pkg/apis/prowjobs/v1/types.go#L134: field Status has omitempty tag which has no effect on struct type sigs.k8s.io/prow/pkg/apis/prowjobs/v1.ProwJobStatus
https://go-mod-viewer.appspot.com/github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/pkg/apis/vmcontroller/v1/types.go#L106: field Storage has omitempty tag which has no effect on struct type github.com/verrazzano/verrazzano-monitoring-operator/pkg/apis/vmcontroller/v1.Storage
https://go-mod-viewer.appspot.com/github.com/dhax/go-base@v0.0.0-20231004214136-8be7e5c1972b/auth/pwdless/account.go#L17: field CreatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/crossplane/upjet@v1.3.0/pkg/terraform/files.go#L290: field Terraform has omitempty tag which has no effect on struct type github.com/crossplane/upjet/pkg/terraform.Terraform
https://go-mod-viewer.appspot.com/open-cluster-management.io/governance-policy-propagator@v0.13.0/api/v1/policy_types.go#L119: field LastTimestamp has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api-provider-azure@v1.14.3/api/v1beta1/types_template.go#L68: field APIServerLB has omitempty tag which has no effect on struct type sigs.k8s.io/cluster-api-provider-azure/api/v1beta1.LoadBalancerClassSpec
https://go-mod-viewer.appspot.com/github.com/dim13/unifi@v0.0.0-20230308161331-9b04946f5e93/event.go#L340: field HandledTime has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L10421: field GoldenTags has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.EntityGoldenContextScopedGoldenTags
https://go-mod-viewer.appspot.com/github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.1.0/pkg/papi/propertyhostname.go#L59: field CertStatus has omitempty tag which has no effect on struct type github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi.CertStatusItem
https://go-mod-viewer.appspot.com/github.com/ThingsIXFoundation/types@v0.0.0-20240308101114-50a3a2f38dce/mapping_discovery_receipt_record.go#L34: field GatewayTime has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/saferwall/pe@v1.5.2/file.go#L34: field CLR has omitempty tag which has no effect on struct type github.com/saferwall/pe.CLRData
https://go-mod-viewer.appspot.com/github.com/sacloud/libsacloud/v2@v2.32.3/sacloud/zz_envelopes.go#L3057: field Start has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/iam/v1alpha2/types.go#L306: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/schmorrison/Zoho@v1.1.4/crm/users.go#L116: field Profile has omitempty tag which has no effect on type struct{Name string "json:"name,omitempty""; ID string "json:"id,omitempty""}
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/alerts/conditions.go#L356: field Condition has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/alerts.Condition
https://go-mod-viewer.appspot.com/github.com/argoproj/argo-cd/v2@v2.10.9/pkg/apis/application/v1alpha1/types.go#L949: field Summary has omitempty tag which has no effect on struct type github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1.ApplicationSummary
https://go-mod-viewer.appspot.com/github.com/FusionAuth/go-client@v0.0.0-20240425220342-2317e10dfcf5/pkg/fusionauth/Domain.go#L4029: field FailedAuthenticationConfiguration has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.FailedAuthenticationConfiguration
https://go-mod-viewer.appspot.com/github.com/k8ssandra/cass-operator@v1.20.0/apis/control/v1alpha1/cassandratask_types.go#L189: field Status has omitempty tag which has no effect on struct type github.com/k8ssandra/cass-operator/apis/control/v1alpha1.CassandraTaskStatus
https://go-mod-viewer.appspot.com/github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.1.0/pkg/appsec/export_configuration.go#L420: field IPGeoFirewall has omitempty tag which has no effect on type struct{Block string "json:"block""; GeoControls struct{BlockedIPNetworkLists struct{NetworkList []string "json:"networkList,omitempty""} "json:"blockedIPNetworkLists""} "json:"geoControls""; IPControls struct{AllowedIPNetworkLists struct{NetworkList []string "json:"networkList,omitempty""} "json:"allowedIPNetworkLists""; BlockedIPNetworkLists struct{NetworkList []string "json:"networkList,omitempty""} "json:"blockedIPNetworkLists""} "json:"ipControls""; UkraineGeoControls struct{UkraineGeoControl struct{Action string "json:"action""}} "json:"ukraineGeoControl,omitempty""}

@timothy-king
Copy link
Contributor

Here are 100 randomly selected diagnostics out of 35104 (allows ast.IsGenerated files):
https://go-mod-viewer.appspot.com/github.com/libvirt/libvirt-go-xml@v7.4.0+incompatible/nwfilter.go#L117: field State has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/replication_execution.go#L24: field EndTime has omitempty tag which has no effect on struct type github.com/go-openapi/strfmt.DateTime
https://go-mod-viewer.appspot.com/github.com/verrazzano/verrazzano@v1.7.1/tools/vz/pkg/internal/util/cluster/rancher/catalogapps.go#L20: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/jenkins-x/jx-api@v0.0.24/pkg/apis/jenkins.io/v1/types_environment.go#L48: field Source has omitempty tag which has no effect on struct type github.com/jenkins-x/jx-api/pkg/apis/jenkins.io/v1.EnvironmentRepository
https://go-mod-viewer.appspot.com/github.com/crowdsecurity/crowdsec@v1.6.1/pkg/types/event.go#L44: field Appsec has omitempty tag which has no effect on struct type github.com/crowdsecurity/crowdsec/pkg/types.AppsecEvent
https://go-mod-viewer.appspot.com/github.com/jfrog/jfrog-cli-core/v2@v2.51.0/artifactory/commands/oc/startbuild.go#L256: field ClientVersion has omitempty tag which has no effect on struct type github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/oc.clientVersion
https://go-mod-viewer.appspot.com/github.com/vmware/go-vcloud-director/v2@v2.24.0/types/v56/cse.go#L55: field OccurredAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/verrazzano/verrazzano@v1.7.1/platform-operator/controllers/verrazzano/component/clusterapi/clusterapi_overrides.go#L35: field OCI has omitempty tag which has no effect on struct type github.com/verrazzano/verrazzano/platform-operator/controllers/verrazzano/component/clusterapi.capiProvider
https://go-mod-viewer.appspot.com/github.com/onosproject/onos-api/go@v0.10.32/onos/config/v3/value.pb.go#L212: field Value has omitempty tag which has no effect on struct type github.com/onosproject/onos-api/go/onos/config/v3.TypedValue
https://go-mod-viewer.appspot.com/github.com/redhat-appstudio/release-service@v0.0.0-20240507143925-083712697924/api/v1alpha1/release_types.go#L480: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/kubernetes-csi/external-snapshotter/client/v4@v4.2.0/apis/volumesnapshot/v1/types.go#L235: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/apis/ca/v1/ca.go#L372: field WriteInterval has omitempty tag which has no effect on struct type github.com/IBM-Blockchain/fabric-operator/pkg/apis/common.Duration
https://go-mod-viewer.appspot.com/github.com/banzaicloud/istio-operator/pkg/apis@v0.10.8/istio/v1beta1/istio_types.go#L252: field Egress has omitempty tag which has no effect on struct type github.com/banzaicloud/istio-operator/pkg/apis/istio/v1beta1.GatewayConfiguration
https://go-mod-viewer.appspot.com/github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/policyrecommendationscope.go#L58: field NamespaceSpec has omitempty tag which has no effect on struct type github.com/tigera/api/pkg/apis/projectcalico/v3.PolicyRecommendationScopeNamespaceSpec
https://go-mod-viewer.appspot.com/github.com/LINBIT/golinstor@v0.52.0/client/controllerconfig.go#L23: field Db has omitempty tag which has no effect on struct type github.com/LINBIT/golinstor/client.ControllerConfigDb
https://go-mod-viewer.appspot.com/github.com/verrazzano/verrazzano@v1.7.1/application-operator/apis/clusters/v1alpha1/verrazzanoproject_types.go#L35: field Spec has omitempty tag which has no effect on struct type k8s.io/api/networking/v1.NetworkPolicySpec
https://go-mod-viewer.appspot.com/github.com/cloudnative-id/community-operator@v0.0.6/pkg/apis/community/v1alpha1/weekly_types.go#L46: field Spec has omitempty tag which has no effect on struct type github.com/cloudnative-id/community-operator/pkg/apis/community/v1alpha1.WeeklySpec
https://go-mod-viewer.appspot.com/kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/types/v1beta1/federatedstatefulset_types.go#L49: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/crosbymichael/octokat@v0.0.0-20160826194511-076a32289ed5/gist.go#L26: field UpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/sigs.k8s.io/gateway-api@v1.0.0/apis/v1alpha2/udproute_types.go#L41: field Status has omitempty tag which has no effect on struct type sigs.k8s.io/gateway-api/apis/v1alpha2.UDPRouteStatus
https://go-mod-viewer.appspot.com/github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/kanban/operation.go#L67: field ClientData has omitempty tag which has no effect on struct type github.com/erda-project/erda-infra/providers/component-protocol/components/kanban.OpBoardUpdateClientData
https://go-mod-viewer.appspot.com/github.com/edwarnicke/govpp@v0.0.0-20230130211138-14ef5d20b1d0/binapi/pnat/pnat.ba.go#L246: field Match has omitempty tag which has no effect on struct type github.com/edwarnicke/govpp/binapi/pnat.PnatMatchTuple
https://go-mod-viewer.appspot.com/github.com/daeMOn63/bitclient@v0.0.0-20190425080230-bfee94efac35/types.go#L238: field DefaultStrategy has omitempty tag which has no effect on struct type github.com/daeMOn63/bitclient.PullRequestStrategy
https://go-mod-viewer.appspot.com/github.com/networkservicemesh/govpp@v0.0.0-20240328101142-8a444680fbba/binapi/wireguard/wireguard.ba.go#L770: field Peer has omitempty tag which has no effect on struct type github.com/networkservicemesh/govpp/binapi/wireguard.WireguardPeer
https://go-mod-viewer.appspot.com/github.com/plutov/paypal/v4@v4.7.1/types.go#L435: field RefundAmount has omitempty tag which has no effect on struct type github.com/plutov/paypal/v4.Money
https://go-mod-viewer.appspot.com/github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/pkg/db/ent/currency.go#L35: field MarketValueLow has omitempty tag which has no effect on struct type github.com/shopspring/decimal.Decimal
https://go-mod-viewer.appspot.com/github.com/mweagle/Sparta@v1.15.0/lambda_permissions.go#L142: field Filter has omitempty tag which has no effect on struct type github.com/aws/aws-sdk-go/service/s3.NotificationConfigurationFilter
https://go-mod-viewer.appspot.com/github.com/charmbracelet/glamour@v0.7.0/ansi/style.go#L23: field NameFunction has omitempty tag which has no effect on struct type github.com/charmbracelet/glamour/ansi.StylePrimitive
https://go-mod-viewer.appspot.com/github.com/hscells/guru@v0.0.0-20200207042420-2dabeb950d69/medgen.go#L150: field CHierarchyUrl has omitempty tag which has no effect on struct type github.com/hscells/guru.CHierarchyUrl
https://go-mod-viewer.appspot.com/github.com/libvirt/libvirt-go-xml@v7.4.0+incompatible/nwfilter.go#L135: field ARPSrcMACAddr has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/sigs.k8s.io/gateway-api@v1.0.0/apis/v1/gatewayclass_types.go#L263: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/drone/runner-go@v1.12.0/manifest/cond.go#L30: field Event has omitempty tag which has no effect on struct type github.com/drone/runner-go/manifest.Condition
https://go-mod-viewer.appspot.com/github.com/crewjam/saml@v0.4.14/metadata.go#L405: field ValidUntil has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/GoogleContainerTools/kpt/porch/api@v0.0.0-20240427025202-5cbd3cbd9237/porch/types_package.go#L28: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/libvirt/libvirt-go-xml@v7.4.0+incompatible/nwfilter.go#L177: field Match has omitempty tag which has no effect on struct type github.com/libvirt/libvirt-go-xml.NWFilterField
https://go-mod-viewer.appspot.com/github.com/VirtusLab/jenkins-operator@v0.0.3/pkg/apis/virtuslab/v1alpha1/jenkins_types.go#L15: field Master has omitempty tag which has no effect on struct type github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1.JenkinsMaster
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L9304: field Account has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/accounts.AccountOutline
https://go-mod-viewer.appspot.com/github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/filter/operation.go#L25: field ClientData has omitempty tag which has no effect on struct type github.com/erda-project/erda-infra/providers/component-protocol/components/filter.OpFilterClientData
https://go-mod-viewer.appspot.com/github.com/subosito/twilio@v0.0.1/call.go#L25: field EndTime has omitempty tag which has no effect on struct type github.com/subosito/twilio.Timestamp
https://go-mod-viewer.appspot.com/github.com/frankrap/okex-api@v1.0.4/margin_results.go#L37: field CurrencyQTUM has omitempty tag which has no effect on struct type github.com/frankrap/okex-api.MarginCurrency
https://go-mod-viewer.appspot.com/github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/models/buyer.go#L7: field Document has omitempty tag which has no effect on struct type github.com/mundipagg/boleto-api/models.Document
https://go-mod-viewer.appspot.com/github.com/pivotal-cf/go-pivnet/v6@v6.0.2/release_dependencies.go#L19: field Release has omitempty tag which has no effect on struct type github.com/pivotal-cf/go-pivnet/v6.DependentRelease
https://go-mod-viewer.appspot.com/github.com/edwarnicke/govpp@v0.0.0-20230130211138-14ef5d20b1d0/binapi/ip/ip.ba.go#L1282: field Table has omitempty tag which has no effect on struct type github.com/edwarnicke/govpp/binapi/ip.IPTable
https://go-mod-viewer.appspot.com/github.com/twilio/twilio-go@v1.20.1/rest/flex/v1/model_list_interaction_channel_invite_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/flex/v1.ListChannelResponseMeta
https://go-mod-viewer.appspot.com/github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cdm/v1/job/requests.go#L49: field FromConfigValues has omitempty tag which has no effect on struct type github.com/chnsz/golangsdk/openstack/cdm/v1/job.JobConfigs
https://go-mod-viewer.appspot.com/github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/common/models/state_proof_sig_slot.go#L9: field Signature has omitempty tag which has no effect on struct type github.com/algorand/go-algorand-sdk/client/v2/common/models.StateProofSignature
https://go-mod-viewer.appspot.com/github.com/openshift/aws-account-operator/pkg/apis@v0.0.0-20220908090753-666f6cd72cfc/aws/v1alpha1/awsfederatedrole_types.go#L127: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/projectcalico/api@v0.0.0-20231218190037-9183ab93f33e/pkg/apis/projectcalico/v3/profile.go#L43: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/giantswarm/apiextensions/v6@v6.6.0/pkg/apis/provider/v1alpha1/status_types.go#L132: field LastTransitionTime has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.Time
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L5415: field ApmBrowserSummary has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.ApmBrowserApplicationSummaryData
https://go-mod-viewer.appspot.com/github.com/PagerDuty/go-pagerduty@v1.8.0/log_entry.go#L34: field Channel has omitempty tag which has no effect on struct type github.com/PagerDuty/go-pagerduty.Channel
https://go-mod-viewer.appspot.com/github.com/ray-project/kuberay/ray-operator@v1.1.1/apis/ray/v1alpha1/raycluster_types.go#L135: field DesiredGPU has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/api/resource.Quantity
https://go-mod-viewer.appspot.com/github.com/argoproj-labs/argocd-operator@v0.10.0/api/v1alpha1/argocd_types.go#L759: field Repo has omitempty tag which has no effect on struct type github.com/argoproj-labs/argocd-operator/api/v1alpha1.ArgoCDRepoSpec
https://go-mod-viewer.appspot.com/github.com/verrazzano/verrazzano@v1.7.1/platform-operator/apis/verrazzano/v1alpha1/verrazzano_types.go#L58: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/waldiirawan/apm-agent-go/v2@v2.2.2/model/model.go#L634: field Code has omitempty tag which has no effect on struct type github.com/waldiirawan/apm-agent-go/v2/model.ExceptionCode
https://go-mod-viewer.appspot.com/github.com/osrg/gobgp@v2.0.0+incompatible/internal/pkg/config/bgp_configs.go#L1345: field State has omitempty tag which has no effect on struct type github.com/osrg/gobgp/internal/pkg/config.VrfState
https://go-mod-viewer.appspot.com/github.com/polygon-io/client-go@v1.16.4/rest/models/dividends.go#L168: field PayDate has omitempty tag which has no effect on struct type github.com/polygon-io/client-go/rest/models.Date
https://go-mod-viewer.appspot.com/github.com/spotahome/redis-operator@v1.2.4/api/redisfailover/v1/types.go#L52: field Exporter has omitempty tag which has no effect on struct type github.com/spotahome/redis-operator/api/redisfailover/v1.Exporter
https://go-mod-viewer.appspot.com/github.com/instill-ai/component@v0.16.0-beta/pkg/connector/huggingface/v0/structs.go#L99: field Options has omitempty tag which has no effect on struct type github.com/instill-ai/component/pkg/connector/huggingface/v0.Options
https://go-mod-viewer.appspot.com/github.com/docker/compose-on-kubernetes@v0.5.0/api/compose/v1beta1/stack.go#L11: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api/bootstrap/kubeadm@v0.0.0-20191016155141-23a891785b60/kubeadm/v1beta2/types.go#L87: field ControllerManager has omitempty tag which has no effect on struct type sigs.k8s.io/cluster-api/bootstrap/kubeadm/kubeadm/v1beta2.ControlPlaneComponent
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/entities/types.go#L4082: field ErrorGroup has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/entities.ErrorTrackingErrorGroup
https://go-mod-viewer.appspot.com/sigs.k8s.io/kueue@v0.6.2/apis/kueue/v1beta1/workload_types.go#L326: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/openebs/api@v1.12.0/pkg/apis/openebs.io/v1alpha1/blockdevice_types.go#L32: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api@v1.7.1/internal/apis/core/exp/addons/v1alpha4/clusterresourcesetbinding_types.go#L115: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api-provider-aws@v1.5.5/bootstrap/eks/api/v1alpha4/eksconfig_types.go#L67: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/gravitational/teleport/api@v0.0.0-20240507183017-3110591cbafc/types/types.pb.go#L1464: field MongoAtlas has omitempty tag which has no effect on struct type github.com/gravitational/teleport/api/types.MongoAtlas
https://go-mod-viewer.appspot.com/github.com/hyperledger/aries-framework-go@v0.3.2/pkg/didcomm/protocol/mediator/models.go#L19: field Timing has omitempty tag which has no effect on struct type github.com/hyperledger/aries-framework-go/pkg/didcomm/protocol/decorator.Timing
https://go-mod-viewer.appspot.com/go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/binapi/vpp2106/sr/sr.ba.go#L149: field XconnectNhAddr has omitempty tag which has no effect on struct type go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/ip_types.Address
https://go-mod-viewer.appspot.com/github.com/open-cluster-management/multicloud-operators-foundation@v1.0.0/pkg/apis/mcm/v1beta1/clusterstatus_types.go#L49: field KlusterletEndpoint has omitempty tag which has no effect on struct type k8s.io/api/core/v1.EndpointAddress
https://go-mod-viewer.appspot.com/github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/api/v1alpha1/idler_types.go#L80: field Spec has omitempty tag which has no effect on struct type github.com/codeready-toolchain/api/api/v1alpha1.IdlerSpec
https://go-mod-viewer.appspot.com/github.com/wtfutil/wtf@v0.43.0/modules/newrelic/client/application_hosts.go#L40: field EndUserSummary has omitempty tag which has no effect on struct type github.com/wtfutil/wtf/modules/newrelic/client.ApplicationHostEndUserSummary
https://go-mod-viewer.appspot.com/github.com/osrg/gobgp@v2.0.0+incompatible/internal/pkg/config/bgp_configs.go#L3417: field PrefixLimit has omitempty tag which has no effect on struct type github.com/osrg/gobgp/internal/pkg/config.PrefixLimit
https://go-mod-viewer.appspot.com/github.com/FusionAuth/go-client@v0.0.0-20240425220342-2317e10dfcf5/pkg/fusionauth/Domain.go#L1369: field Phone has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.Requirable
https://go-mod-viewer.appspot.com/github.com/edwarnicke/govpp@v0.0.0-20230130211138-14ef5d20b1d0/binapi/mfib_types/mfib_types.ba.go#L145: field Path has omitempty tag which has no effect on struct type github.com/edwarnicke/govpp/binapi/fib_types.FibPath
https://go-mod-viewer.appspot.com/github.com/kubeflow/training-operator@v1.7.0/pkg/apis/kubeflow.org/v1/pytorch_types.go#L163: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/infobloxopen/infoblox-go-client@v1.1.1/objects.go#L154: field Lan2PhysicalSetting has omitempty tag which has no effect on struct type github.com/infobloxopen/infoblox-go-client.PhysicalPortSetting
https://go-mod-viewer.appspot.com/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring@v0.73.2/v1/prometheus_types.go#L344: field Resources has omitempty tag which has no effect on struct type k8s.io/api/core/v1.ResourceRequirements
https://go-mod-viewer.appspot.com/github.com/kotovmak/go-admin@v1.1.1/modules/config/config.go#L357: field Animation has omitempty tag which has no effect on struct type github.com/kotovmak/go-admin/modules/config.PageAnimation
https://go-mod-viewer.appspot.com/github.com/kube-logging/logging-operator/pkg/sdk@v0.11.0/extensions/api/v1alpha1/hosttailer_types.go#L64: field Spec has omitempty tag which has no effect on struct type github.com/kube-logging/logging-operator/pkg/sdk/extensions/api/v1alpha1.HostTailerSpec
https://go-mod-viewer.appspot.com/github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-packer-service/stable/2021-04-30/models/hashicorp_cloud_packer_bucket_latest_iteration.go#L41: field CreatedAt has omitempty tag which has no effect on struct type github.com/go-openapi/strfmt.DateTime
https://go-mod-viewer.appspot.com/github.com/banzaicloud/operator-tools@v0.28.10/pkg/prometheus/servicemonitor.go#L145: field Password has omitempty tag which has no effect on struct type k8s.io/api/core/v1.SecretKeySelector
https://go-mod-viewer.appspot.com/github.com/twilio/twilio-go@v1.20.1/rest/chat/v1/model_list_user_channel_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/chat/v1.ListChannelResponseMeta
https://go-mod-viewer.appspot.com/github.com/dgraph-io/dgraph@v1.2.8/graphql/admin/schema.go#L63: field Set has omitempty tag which has no effect on struct type github.com/dgraph-io/dgraph/graphql/admin.gqlSchema
https://go-mod-viewer.appspot.com/kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/notification/v2beta2/notificationmanager_types.go#L336: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/golang.org/x/build@v0.0.0-20240506185731-218518f32b70/kubernetes/api/types.go#L2394: field ObjectMeta has omitempty tag which has no effect on struct type golang.org/x/build/kubernetes/api.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/sacloud/iaas-api-go@v1.12.0/zz_envelopes.go#L1494: field End has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/apis/peer/v1/peer.go#L327: field Cert has omitempty tag which has no effect on struct type github.com/IBM-Blockchain/fabric-operator/pkg/apis/peer/v1.File
https://go-mod-viewer.appspot.com/sigs.k8s.io/cluster-api-provider-aws@v1.5.5/exp/api/v1alpha4/awsmachinepool_types.go#L207: field ListMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta
https://go-mod-viewer.appspot.com/github.com/digitalocean/go-netbox@v0.0.2/netbox/models/config_context.go#L49: field Created has omitempty tag which has no effect on struct type github.com/go-openapi/strfmt.Date
https://go-mod-viewer.appspot.com/github.com/greenpau/go-authcrunch@v1.1.4/pkg/identity/user.go#L66: field LastModified has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/banzaicloud/operator-tools@v0.28.10/pkg/resources/overlay.go#L39: field ObjectKey has omitempty tag which has no effect on struct type github.com/banzaicloud/operator-tools/pkg/types.ObjectKey
https://go-mod-viewer.appspot.com/github.com/twilio/twilio-go@v1.20.1/rest/chat/v2/model_list_user_response.go#L20: field Meta has omitempty tag which has no effect on struct type github.com/twilio/twilio-go/rest/chat/v2.ListBindingResponseMeta
https://go-mod-viewer.appspot.com/github.com/newrelic/newrelic-client-go@v1.1.0/pkg/apiaccess/keys.go#L178: field Key has omitempty tag which has no effect on struct type github.com/newrelic/newrelic-client-go/pkg/apiaccess.APIKey
https://go-mod-viewer.appspot.com/sigs.k8s.io/kueue@v0.6.2/apis/kueue/v1alpha1/multikueue_types.go#L81: field ObjectMeta has omitempty tag which has no effect on struct type k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta
https://go-mod-viewer.appspot.com/github.com/CyCoreSystems/ari@v4.8.4+incompatible/events_gen.go#L727: field ReplaceChannel has omitempty tag which has no effect on struct type github.com/CyCoreSystems/ari.ChannelData
https://go-mod-viewer.appspot.com/github.com/minio/mc@v0.0.0-20240507152021-646712d5e5fb/cmd/ilm-rule-export.go#L60: field UpdatedAt has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/oam-dev/kubevela@v1.9.11/references/appfile/api/appfile.go#L52: field UpdateTime has omitempty tag which has no effect on struct type time.Time
https://go-mod-viewer.appspot.com/github.com/r0busta/go-shopify-graphql-model@v0.0.4/graph/model/models_gen.go#L9195: field Title has omitempty tag which has no effect on struct type gopkg.in/guregu/null.v4.String
https://go-mod-viewer.appspot.com/github.com/FusionAuth/go-client@v0.0.0-20240425220342-2317e10dfcf5/pkg/fusionauth/Domain.go#L6479: field Field has omitempty tag which has no effect on struct type github.com/FusionAuth/go-client/pkg/fusionauth.FormField

@thw0rted
Copy link

thw0rted commented Sep 9, 2024

It looks like #11939 was just closed in favor of a new tag, omitzero. As I suggested earlier in the year, I believe the scope of this proposal should be broadened such that the omitempty tag generates a vet / analysis-framework warning any time it is used in a place where it has no meaning, that is, in places where the new omitzero tag should be used instead.

ETA: ...which, I believe, is exactly what the "candidate implementation" / https://go-review.googlesource.com/c/tools/+/388574 was supposed to do. That review is marked as "abandoned" -- any chance of getting the ball rolling again? It looks like this proposal here has to be resolved first...

@ianlancetaylor ianlancetaylor changed the title proposal: cmd/vet: warn about time.Time struct fields marked json omitempty proposal: cmd/vet: warn about structs marked json omitempty Sep 10, 2024
@rsc
Copy link
Contributor

rsc commented Sep 11, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Sep 11, 2024
@andig
Copy link
Contributor

andig commented Sep 11, 2024

Awesome! The fact that even Go standard library likes to promote this mistake speaks for itself. Follow-up proposal would be if "fixing" go standard library goes against compatibility promise (oauth2.Token anyone?).

@aclements
Copy link
Member

As I suggested earlier in the year, I believe the scope of this proposal should be broadened such that the omitempty tag generates a vet / analysis-framework warning any time it is used in a place where it has no meaning, that is, in places where the new omitzero tag should be used instead.

My instinct is that, practically speaking, this is far more of a problem for struct fields than anything else, but I would love to see some data on that. @timothy-king , since you have the pipeline for checking for omitempty struct fields, could you check for meaningless omitempty fields of other kinds?

@dsnet
Copy link
Member

dsnet commented Oct 2, 2024

I should note that the v2 experiment alters the definition of omitempty such that it works and doesn't work in a different set of circumstances: #63397 (comment)

To be specific:

The omitempty option in v2 is redefined relative to v1, and this could cause compatibility issues. Despite the change in semantics, they generally produce the same result in most cases except the following:

  • Go bools and numeric kinds (e.g., int, float32, etc.) cannot be omitted with omitempty in v2 since the proposed definition of an empty JSON value does not include false or 0 (example).
  • Go pointers and interfaces may be omitted in v2 but not v1 if the underlying value encodes as an empty JSON value. For example, an empty string stored in an interface or a non-null pointer to an empty struct will operate differently under v2 semantics (example).

In both cases, the v1 semantics can be obtained by using the omitzero option.

Under the v2 definition, omitempty could be meaningful on a struct type if:

  • that type has a custom MarshalJSON method (which might emit null, "", [], or {}),
  • that type itself has fields with omitzero or omitempty, or
  • that type has no JSON serializable fields (not sure how this is useful).

Under the v2 definition, omitempty is not meaningful on numeric or boolean values (that don't have a MarshalJSON method).

@aclements
Copy link
Member

So.. if we add this vet check now, it'll mess up json/v2 in the future? That's unfortunate.

I believe vet can see all of the conditions for omitempty to be meaningful (or meaningless) in json/v2. Hence, we could implement the basic check for now, and if/when json/v2 lands we can update vet to support the more liberal validity of omitempty used by json/v2. Does that seem reasonable, @dsnet ?

@dsnet
Copy link
Member

dsnet commented Oct 23, 2024

We have 4 conditions:

  1. valid under both v1 and v2
  2. valid under v1 but not valid under v2
  3. not valid under v1 but valid underv2
  4. not valid under both v1 and v2

I believe we should initially implement this vet check in such a way that it only detects case 4.

More concisely, vet reports a problem if:

  • a field is marked with omitempty AND
  • the type of the field does not implement MarshalJSON or MarshalText AND
    • is an array of non-zero length OR
    • a struct type that has at least 1 JSON serializable field not marked by omitempty or omitzero (in other words, this value cannot possibly be serialized as just {}).

In the future (after 2 releases), we can expand it to detect case 2, where:

  • If omitempty is specified on a bool, int, uint, or float, we suggest the use of omitzero instead.

@aclements
Copy link
Member

Thanks. That logic all seems fine.

@aclements
Copy link
Member

If omitempty is specified on a bool, int, uint, or float, we suggest the use of omitzero instead.

Thinking a little more about this, I believe this should be written in terms of underlying types and exclude named types with MarshalJSON or MarshalText. In other words, I think this addition becomes a third OR in your second level of bullets.

@aclements
Copy link
Member

Sorry, another thought: In encoding/json v1, there's nothing wrong with using omitempty on bool/int/uint/float types. IIUC, it does the same thing as the new omitzero. Adding a vet check suggesting that the user switch to omitzero is equivalent to deprecating that aspect of omitempty. Given that, and given that it wouldn't happen until 1.26 anyway, I wonder if the suggestion of switching to omitzero should be its own discussion.

@aclements
Copy link
Member

Discussing this with the proposal committee, we're skeptical of de facto deprecating the current behavior of omitempty on bool and numeric types. We can make it a matter of documented policy that new code should use omitzero, but we believe there's a lot of code currently using omitempty in meaningful ways for these types.

When and if encoding/json/v2 lands, we can think about a more precise check there. I'm not sure what that would look like, but one possibility would be to add the stricter vet check if a module directly imports v2 and only v2.

@aclements
Copy link
Member

Partly just because I did the work of writing it down, if we were to include the omitempty deprecation, I believe this is the exact logic:

Vet would report a meaningless use of encoding/json's omitempty field tag if:

  1. Struct field F is marked with omitempty AND
  2. The type of F does not implement MarshalJSON or MarshalText AND
    1. F's type is an array of non-zero length OR
    2. F's type is a struct type that has at least 1 JSON serializable field not marked by omitempty or omitzero (in other words, this value cannot possibly be serialized as just {}) OR
    3. Starting in Go 1.26 (once all supported Go versions support omitzero), type underlying type of F is bool, or an integer, unsigned integer, or float type.

In case 2c, vet would suggest using omitzero instead of omitempty.

@aclements
Copy link
Member

Have all remaining concerns about this proposal been addressed?

The proposal is to add a vet check that reports meaningless uses of encoding/json's omitempty field tag if:

  1. Struct field F is marked with omitempty AND
  2. The type of F does not implement MarshalJSON or MarshalText AND
    1. F's type is an array of non-zero length OR
    2. F's type is a struct type that has at least 1 JSON serializable field not marked by omitempty or omitzero (in other words, this value cannot possibly be serialized as just {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) Proposal
Projects
Status: Active
Development

Successfully merging a pull request may close this issue.