-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
REST API: "\u003cmissing\u003e" instead of "<missing>" in returned Id attribute ( /v1.24/images/${img}/history ) #17769
Comments
A friendly reminder that this issue had no activity for 30 days. |
It seems that it's pretty easily fixable with the following: diff --git a/pkg/api/handlers/utils/handler.go b/pkg/api/handlers/utils/handler.go
index f2f8ab1dc..2e457c39e 100644
--- a/pkg/api/handlers/utils/handler.go
+++ b/pkg/api/handlers/utils/handler.go
@@ -160,7 +160,7 @@ func WriteJSON(w http.ResponseWriter, code int, value interface{}) {
w.WriteHeader(code)
coder := json.NewEncoder(w)
- coder.SetEscapeHTML(true)
+ coder.SetEscapeHTML(false)
if err := coder.Encode(value); err != nil {
logrus.Errorf("Unable to write json: %q", err)
} It strikes me as being possibly dangerous, though, to disable escaping HTML chars for an encoding issue, when tools like |
Maybe it's correct that you are saying, @nwoythal. If we examine the Moby project, you can check the WriteJSON function at this link: /~https://github.com/moby/moby/blob/b33ad6fff6123f16f042d15623194f5c4bcd3ea6/api/server/httputils/httputils.go#L94, where the escape HTML is set to false. |
I see now that the ID is displayed in this way: |
I noticed that Podman and Docker had different values for the Size field so I opened a new issue for that |
I tried out the reproducer on Fedora 39 with podman 4.8.1
I got the same result as before but with a small difference. There is a colon Here is the whole output (without using
I formatted the outputs with --- /tmp/jq-output.podman 2023-12-07 21:48:35.263207666 +0100
+++ /tmp/jq-output.docker 2023-12-07 21:48:27.174388226 +0100
@@ -6,17 +6,15 @@
"Id": "sha256:b2aa39c304c27b96c1fef0c06bee651ac9241d49c4fe34381cab8453f9a89c7d",
"Size": 0,
"Tags": [
- "docker.io/library/alpine:3.17.2"
+ "alpine:3.17.2"
]
},
{
"Comment": "",
"Created": 1676090802,
"CreatedBy": "/bin/sh -c #(nop) ADD file:40887ab7c06977737e63c215c9bd297c0c74de8d12d16ebdf1c3d40ac392f62d in / ",
- "Id": "sha256:<missing>",
- "Size": 7337984,
- "Tags": [
- "docker.io/library/alpine:3.17.2"
- ]
+ "Id": "<missing>",
+ "Size": 7049701,
+ "Tags": null
}
] Note the extra |
Issue Description
In the JSON ouput from the REST API (/v1.24/images/${img}/history)
docker returns
podman returns
I guess both variants are just two ways to represent the same JSON content so one could argue if this issue is really a bug, but I think there will be less incompatibility issues with docker if podman would use the same output.
(There might be buggy clients that are using the REST API although I haven't seen any examples of problems related to this issue)
Steps to reproduce the issue
On a Fedora 37 computer (arch: amd64)
sudo -i
dnf install -y podman
dnf install -y moby-engine
systemctl start docker
useradd test1
usermod -aG docker test1
machinectl shell test1@
podman pull alpine:3.17.2
podman images
and detect the image id. Record the result in a shell variableimg=b2aa39c304c2
docker pull alpine:3.17.2
systemctl --user start podman.socket
curl -s --unix-socket /var/run/docker.sock http://localhost/v1.24/images/${img}/history | grep -o -P '.{0,7}missing.{0,7}'
curl -s --unix-socket $XDG_RUNTIME_DIR/podman/podman.sock http://localhost/v1.24/images/${img}/history | grep -o -P '.{0,7}missing.{0,7}'
Describe the results you received
Describe the results you expected
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: