Skip to content
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

docker rest api compatibility not honored for error responses. #20013

Closed
Alex-Izquierdo opened this issue Sep 18, 2023 · 8 comments
Closed

docker rest api compatibility not honored for error responses. #20013

Alex-Izquierdo opened this issue Sep 18, 2023 · 8 comments
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. HTTP API Bug is in RESTful API kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@Alex-Izquierdo
Copy link

Issue Description

It seems that the compatibility with the api rest of docker is not met for error responses. According to the docker docs, the response should include a field "message" but podman has a different schema.
This can be reproduced easily running a request to pull an image, for example. As consequence, clients like the official python library for docker doesn't work because the response has a different schema (the message is inside "errordetail") and the library expects to have a "message" key at the root level as is described in the docs.

Docker docs ref: https://docs.docker.com/engine/api/v1.43/#tag/Image/operation/ImageCreate
Example of podman response

curl -XPOST "http://localhost:8888/images/create?fromImage=quay.io/idonotexist/idonotexist:dummy" | jq
{
  "progressDetail": {},
  "errorDetail": {
    "message": "initializing source docker://quay.io/idonotexist/idonotexist:dummy: reading manifest dummy in quay.io/idonotexist/idonotexist: unauthorized: access to the requested resource is not authorized"
  },
  "error": "initializing source docker://quay.io/idonotexist/idonotexist:dummy: reading manifest dummy in quay.io/idonotexist/idonotexist: unauthorized: access to the requested resource is not authorized"
}

Tested with latest podman container 4.6.1

Steps to reproduce the issue

curl -XPOST "http://localhost:8888/images/create?fromImage=quay.io/idonotexist/idonotexist:dummy"

Describe the results you received

The response doesn't meet the spec of docker api response, don't have a "message" key in the root level

Describe the results you expected

a "message" key in the root level with the reason of the error.

podman info output

podman v4.6.1

Podman in a container

Yes

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

No response

Additional information

No response

@Alex-Izquierdo Alex-Izquierdo added the kind/bug Categorizes issue or PR as related to a bug. label Sep 18, 2023
@mheon mheon added Good First Issue This issue would be a good issue for a first time contributor to undertake. HTTP API Bug is in RESTful API labels Sep 18, 2023
@rhatdan
Copy link
Member

rhatdan commented Sep 18, 2023

Do you have an example of the Docker response?

Interested in opening a PR to fix this issue?

@Alex-Izquierdo
Copy link
Author

Alex-Izquierdo commented Sep 19, 2023

Hi @rhatdan thanks for your quick response.
This is how looks the response from docker:

root@ubuntu:/var/run# curl --unix-socket /var/run/docker.sock -XPOST "http://localhost/images/create?fromImage=quay.io/idonotexist/idonotexist:dummy"
{"message":"unauthorized: access to the requested resource is not authorized"}

Interested in opening a PR to fix this issue?

It would be my first attempt to contribute to the Podman code, but I'm happy to give it a try. What would be the best approach to fix it? Should we move the "message" field up one level, duplicate it, or rename the current error field?

@rhatdan
Copy link
Member

rhatdan commented Sep 19, 2023

I would move the message field up one level, or just return the message field instead of the entire report message.

@jackgris
Copy link
Contributor

jackgris commented Oct 3, 2023

Hi, after reading this issue I found where the message was created I changed the message to return the error response in the way that Alex commented {"message":"unauthorized: access to the requested resource is not authorized"}. But I was not sure if modifying a type in a vendor package is right for this. I only added a Message field with a json omitempty option.

jackgris added a commit to jackgris/podman that referenced this issue Oct 13, 2023
This is related to the issue containers#20013

Signed-off-by: Gabriel Pozo <[email protected]>
Copy link

github-actions bot commented Nov 3, 2023

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Nov 5, 2023

@jackgris could you open a PR to fix this issue?

@rhatdan
Copy link
Member

rhatdan commented Nov 5, 2023

Actually after looking at the code it looks like @jackgris fix is in Podman, so I am going to assume this is fixed. Reopen if I am mistaken.

@rhatdan rhatdan closed this as completed Nov 5, 2023
@jackgris
Copy link
Contributor

jackgris commented Nov 5, 2023

Yes, I forgot to add another comment here mentioning this: #20239

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Feb 4, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. HTTP API Bug is in RESTful API kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

4 participants