Skip to content

imagetools: validate descriptor input for create -f - #3933

Merged
tonistiigi merged 2 commits into
docker:masterfrom
amarkdotdev:fix/imagetools-create-descriptor-validation
Jul 7, 2026
Merged

imagetools: validate descriptor input for create -f#3933
tonistiigi merged 2 commits into
docker:masterfrom
amarkdotdev:fix/imagetools-create-descriptor-validation

Conversation

@amarkdotdev

Copy link
Copy Markdown
Contributor

Summary

  • Validate JSON passed to imagetools create -f is an OCI content descriptor, not a manifest or index.
  • Reject descriptors with missing or invalid digests before push, returning a clear error instead of panicking.

Fixes #2091

Test plan

  • go test ./commands/imagetools/ -run TestParseSourceDescriptorValidation
  • docker buildx imagetools inspect --raw alpine | docker buildx imagetools create -f /dev/stdin -t example/test returns a descriptive error (no panic)
  • Valid descriptor JSON with digest, mediaType, and size still works

@amarkdotdev

Copy link
Copy Markdown
Contributor Author

@jsternberg @jedevc friendly review request — targets the descriptor validation discussed on #2091 (clear error for manifest/index JSON piped from inspect --raw, plus digest checks). Unit tests included.

Return a clear error when -f contains a manifest or index instead of an OCI
content descriptor, and reject descriptors missing a valid digest. Avoids
a nil-pointer panic when piping inspect --raw output into imagetools create.

Fixes docker#2091


Signed-off-by: amarkdotdev <amarkdotdev@users.noreply.github.com>
@amarkdotdev
amarkdotdev force-pushed the fix/imagetools-create-descriptor-validation branch from 32761fb to 89ec9fe Compare July 6, 2026 20:25

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Commit message says this fixes a panic but I don't think that is correct.

Comment thread commands/imagetools/create.go Outdated
Parse schemaVersion and descriptor fields in a single pass instead of
calling json.Unmarshal twice.

Signed-off-by: amarkdotdev <amarkdotdev@users.noreply.github.com>
@amarkdotdev

amarkdotdev commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@tonistiigi see my latest commit please.

@tonistiigi
tonistiigi merged commit a21f0a4 into docker:master Jul 7, 2026
225 of 226 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic in buildx imagetools create

2 participants