delete-package-versions icon indicating copy to clipboard operation
delete-package-versions copied to clipboard

Cannot read property 'packages' of null

Open ovidals opened this issue 5 years ago • 6 comments

Hi!

I'm using the following code to remove old versions from another repository wich is private:

 - uses: actions/delete-package-versions@v1
    with:
      owner: '---'
      repo: '---'
      package-name: '---'
      num-old-versions-to-delete: 1
      token: ${{ secrets.CI_PACKAGES_READ_DELETE_TOKEN }}

I have created a personal access token with read and write packages permissions and stored as secret on the repository that is firing the action, but this error is thrown:

Cannot read property 'packages' of null

Any help on this?

Thank you!

ovidals avatar Aug 26 '20 15:08 ovidals

Happens for me too when I use ghcr.io (https://docs.github.com/en/packages/getting-started-with-github-container-registry/migrating-to-github-container-registry-for-docker-images)

With this change images are now stored at org level and not package level, maybe this is causing the error

firefart avatar Sep 16 '20 20:09 firefart

Looks like this is the problem as only repository packages are fetched using graqhQL

https://github.com/actions/delete-package-versions/blob/35f1b743a143bad14da97a62245ebb87c046c1e1/src/version/get-versions.ts#L29

firefart avatar Sep 16 '20 20:09 firefart

Have the same issue, @FireFart do you know how to query the new ghcr stored versions ? I used the GraphQL explorer but I do not seem to find any Docker packages, which I have on my private user. I also found this information regarding the registry: https://github.community/t/ghcr-io-docker-http-api/130121 Maybe we can extend the current functionality to fetch from ghcr and then delete from there as well, and open a PR. I Have the same use case as @ovidals

kc1r74p avatar Jan 10 '21 17:01 kc1r74p

Facing almost the same issue using ghcr.io: Error: TypeError: Cannot read property 'node' of undefined

aidmax avatar Jan 11 '21 08:01 aidmax

After searching some more I also found this Info: https://github.community/t/github-container-registry-ghcr-io-packages-not-appearing-in-api/130133 Basically there is no ETA when the GraphQL API will also give out/handle container images, which would enable this action to almost directly work.

I also tried the docker catalog api directly, hoping we could implement it ourselves: ghcr.io/v2/<owner>/<image>/tags/list but it, with all permissions, just returns: { "errors": [ { "code": "DENIED", "message": "invalid token" } ] }

So the only way currently is the GH Frontend which can list/delete the images. Well currently as far as I can tell is, that all we can do is wait. The GH public roadmap also seems not to have much coming up for ghcr.

Also similiar request: https://github.community/t/are-there-plans-to-support-deletions-of-images-in-ghcr/153728 Interesting quote from Staff very recently:

But we’re working on a delete API that could be used on PR merge. Hoping to have this out by end of month.

kc1r74p avatar Jan 11 '21 14:01 kc1r74p

So there was an update on: https://github.community/t/are-there-plans-to-support-deletions-of-images-in-ghcr/153728 which now offers the v3 REST API to list and delete containers from ghcr.io: https://github.community/t/you-can-now-delete-and-restore-any-package-type-within-github-packages/162393

So I did a very rough integration to proof it is working: https://github.com/actions/delete-package-versions/compare/main...kc1r74p:main

I used my fix version like this:

        name: Remove previous version
        uses:  kc1r74p/delete-package-versions@main
        with:
          owner: ${{ github.repository_owner }}
          package-name: '<package_name>'
          package-type: 'container'
          ignore-tag: 'latest'
          token: ${{ secrets.CR_PAT }}

I could try to get a PR going for this repo, just not sure if GraphQL will implement containers in the future which would deprecate this kind of fix. @andymckay Could we get your opinion, might help to decide if we should integrate it or wait further.

Might also solve: https://github.com/actions/delete-package-versions/issues/35

kc1r74p avatar Mar 22 '21 21:03 kc1r74p