coreos / coreos/ignition

Embedded structs missing JSON tags

Open
#917 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
974
Forks
296
Avg merge
6d 14h
Merged PRs (30d)
9

Description

We found this in OpenShift back in https://github.com/openshift/machine-config-operator/pull/955 while running Kubebuilder generators, and hit this again recently, so opening an issue to refer to

Several types are missing JSON tags in their embedded fields, for example:
https://github.com/coreos/ignition/blob/master/config/v3_0/types/schema.go#L24-L27
Which throw errors like encountered struct field "" without JSON tag in type "Directory"

In the discussion of the above linked PR, it seems that the reason for this is wanting to keep these field names from being seen when serialized. However, this could still be accomplished with JSON tags like:

type Directory struct {
	Node `json:",inline"`
	DirectoryEmbedded1 `json:",inline"`
}

Would this change be possible? It would fix errors we are seeing, while still serializing these field names as "invisible" in the JSON

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review config/v3_0/types/schema.go, especially Directory and its embedded fields, and check how the Kubebuilder generator reports fields without JSON tags. Confirm whether adding tags preserves the intended invisible JSON serialization, then validate that the generator no longer reports the cited error; the issue does not name a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.