Deleting a package version for a container on ghcr.io results in a 500 error

I’m trying out the newly released functionality to delete a container image tag on the container registry at ghcr.io via the rest api endpoint documented here

I’m using it like this:

curl -i \
  -X DELETE \
  -H 'Authorization: Bearer the-token' \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/user/packages/container/typescript-monorepo-example-main-internal-api/versions/15

15 in this case is the image tag. Since first trying it yesterday it always results in a 500 error with the following headers and payload:

HTTP/2 500 
server: GitHub.com
date: Tue, 23 Feb 2021 16:17:13 GMT
content-type: application/json; charset=utf-8
content-length: 168
x-oauth-scopes: delete:packages, repo, write:packages
x-accepted-oauth-scopes: 
x-github-media-type: github.v3; format=json
x-ratelimit-limit: 5000
x-ratelimit-remaining: 4993
x-ratelimit-reset: 1614099741
x-ratelimit-used: 7
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'
vary: Accept-Encoding, Accept, X-Requested-With
x-github-request-id: C510:36C4:689C:9570:60352A89

{
  "message": "Internal server error.",
  "documentation_url": "https://docs.github.com/rest/reference/packages#delete-a-package-version-for-the-authenticated-user"
}

Deleting the whole package without specifying a version (tag) works fine.

1 Like

You need to use the version ID, not the tag, as listed in the response to the https://api.github.com/user/packages/container/{package}/versions endpoint.

1 Like

Yes, you are correct. Thank you!

1 Like