docker / hub-feedback

Feedback and bug reports for the Docker Hub
https://hub.docker.com
233 stars 48 forks source link

delete-images API is not working #2294

Closed zamir-devops closed 1 year ago

zamir-devops commented 1 year ago

Problem description

Hi, I'm trying to use the endpoint documented here

That is: https://hub.docker.com/v2/namespaces/{namespace}/delete-images

However when I send the authenticated request, it returns:

{
    "message": "405: Method Not Allowed"
}

I am using different JSON payloads for the request, however it doesn't work with any of them, for example this one

{
    "dry_run": false,
    "manifests": [
        {
            "repository": "coign-test",
            "digest": "sha256:******"
        }
    ],
    "ignore_warnings": []
}

or this one:

{
    "dry_run": true,
    "active_from": "2022-11-01T12:00:00Z",
    "manifests": [
        {
            "repository": "coign-test",
            "digest": "sha256:******"
        }
    ],
    "ignore_warnings": []
}

Also I tested with a recent generated mfa token.

Testing the following endpoint /v2/namespaces/dockercoign/repositories/coign-core/images?status=inactive works, it means it's not related with authentication since I am using the same token (it's not a PAT, login is done via 2FA)

Debug Information

Browser name and version: Postman for Windows Version 9.31.23 UI Version 9.31.23-ui-221108-1820 Desktop Platform Version 9.31.0 Architecture x64 OS Platform win32 10.0.19044

URL: /v2/namespaces/dockercoign/delete-images

Timetamp or time range: UTC -5 CO

Public IP: 186.30.147.142

Hub Username:
dockercoign (org) 6779737178 <- Hub user doing the API calls

Error messages (on screen or in browser console)

{ "message": "405: Method Not Allowed" }

Thanks in advance!

zappy-shu commented 1 year ago

Hi @zamir-devops I've had a flick through the our logs and I can see you've attempted calling this endpoint with the GET HTTP method. Please note that you must use the POST http method (hence the 405 response).

I can see you've tried using POST in some requests but the endpoint was slightly wrong: //v2/namespaces/dockercoign/delete-images.

That double // at the start would break the routing unfortunately.

Please could you try again using POST /v2/namespaces/dockercoign/delete-images and see if that works. You can also try doing this via the Docker Hub interface under Advanced Image Management. That uses the same API underneath that you are consuming here.

Thank you and if you have any issues please get back to us here

zamir-devops commented 1 year ago

@zappy-shu You are totally right, both // and HTTP method were the cause. Thank you so much for the help!

zappy-shu commented 1 year ago

No problem @zamir-devops . Glad I could help.