image-spec icon indicating copy to clipboard operation
image-spec copied to clipboard

Nullability of optional fields in manifests and descriptors

Open tofay opened this issue 3 years ago • 1 comments

It's not clear whether optional fields in manifests and descriptors can be null. By extension, it's also not clear whether or not the canonicalized form of a manifest should omit or set to null any optional fields that are not provided.

I noticed that the config spec and schema allows that optional fields may be null: https://github.com/opencontainers/image-spec/blob/8b9d41f48198a7d6d0a5c1a12dc2d1f7f47fc97f/config.md?plain=1#L93

The schemas for manifests and descriptors don't allow for null values. Should the spec be updated to clarify this? Happy to do that.

tofay avatar Feb 03 '22 08:02 tofay

From the Go implementations, the preference is to omit the field, rather than explicitly set it to null, in the JSON. That's seen with omitempty defined on various fields. I don't believe this is a hard requirement, but it's a convention you'll see from most implementations.

sudo-bmitch avatar Aug 05 '22 20:08 sudo-bmitch