Skip to content

Conversation

@thaJeztah
Copy link
Member

The JSON field was added in moby@9fd2c0f, to address moby#19177, which reported an incompatibility with Classic (V1) Swarm, which produced a non- standard response;

Make docker load to output json when the response content type is json
Swarm hijacks the response from docker load and returns JSON rather
than plain text like the Engine does. This makes the API library to return
information to figure that out.

A later change in moby@96d7db6 added additional logic to make sure the correct content-type was returned, depending on whether the quiet option was set (which produced a non-JSON response). This caused inconsistency in the API response, and moby@2f27632 changed the endpoint to always produce JSON (only skipping the "progress" output if quiet was set).

This means that the "load" endpoint (imageRouter.postImagesLoad) now unconditionally returns JSON, making the JSON field fully redundant.

This patch removes the use of the JSON field, as it's redundant, and the way it handles the content-type is incorrect because it would not handle correct, but different formatted response-headers (application/json; charset=utf-8), which could result in malformed output on the client.

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the 29.0.0 milestone Oct 27, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the use of the redundant JSON field from the ImageLoadResult in the Docker CLI's image load command. Since the Docker Engine's /images/load endpoint now unconditionally returns JSON responses (as of moby@2f27632), the JSON field that was originally added to handle Classic Swarm's non-standard responses is no longer needed. Additionally, the field's content-type handling logic was incorrect as it wouldn't properly handle valid but differently formatted response headers.

Key changes:

  • Simplified the runLoad function to always use jsonstream.Display for processing responses
  • Updated test mocks to return JSON-formatted responses instead of plain text
  • Updated golden test files to reflect the new JSON-based output format

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

File Description
cli/command/image/load.go Removed conditional JSON handling logic and simplified response processing to always use jsonstream.Display
cli/command/image/load_test.go Updated test mocks to return JSON responses and removed the json parameter from mockImageLoadResult
cli/command/image/testdata/*.golden Updated expected test outputs to reflect JSON-formatted responses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The JSON field was added in [moby@9fd2c0f], to address [moby#19177], which
reported an incompatibility with Classic (V1) Swarm, which produced a non-
standard response;

> Make docker load to output json when the response content type is json
> Swarm hijacks the response from docker load and returns JSON rather
> than plain text like the Engine does. This makes the API library to return
> information to figure that out.

A later change in [moby@96d7db6] added additional logic to make sure the
correct content-type was returned, depending on whether the `quiet` option
was set (which produced a non-JSON response). This caused inconsistency in
the API response, and [moby@2f27632] changed the endpoint to always produce
JSON (only skipping the "progress" output if `quiet` was set).

This means that the "load" endpoint ([`imageRouter.postImagesLoad`]) now
unconditionally returns JSON, making the `JSON` field fully redundant.

This patch removes the use of the JSON field, as it's redundant, and the way it handles
the content-type is incorrect because it would not handle correct, but different
formatted response-headers (`application/json; charset=utf-8`), which could
result in malformed output on the client.

[moby@9fd2c0f]: moby/moby@9fd2c0f
[moby#19177]: moby/moby#19177
[moby@96d7db6]: moby/moby@96d7db6
[moby@2f27632]: moby/moby@2f27632
[`imageRouter.postImagesLoad`]: https://github.com/moby/moby/blob/7b9d2ef6e5518a3d3f3cc418459f8df786cfbbd1/api/server/router/image/image_routes.go#L248-L255

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@austinvazquez austinvazquez merged commit 93cd679 into docker:master Oct 28, 2025
87 checks passed
@thaJeztah thaJeztah deleted the no_json branch October 28, 2025 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants