cli: `gh codespace list` shows an instance, but I cannot delete it
Describe the bug
gh version 2.33.0 (2023-08-18)
https://github.com/cli/cli/releases/tag/v2.33.0
When I list my codespaces in my org, I see one that is in a shutdown state, however when I go to delete it via the CLI, I get told I have no codespaces.
Steps to reproduce the behavior
$ gh codespace list --org MY_ORG
NAME DISPLAY NAME OWNER REPOSITORY BRANCH STATE CREATED AT
humble-engine-65rjvwpjgr63r9p5 humble engine USERNAME MY_ORG/technical-interview main* Shutdown 16h
$ gh codespace delete --user USERNAME
error choosing codespace: you have no codespaces
Expected vs actual behavior
I expect that I can delete a codespace that is in the result of the list codespaces command
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 19 (9 by maintainers)
There’s definitely a bug here. I’m following up with the team to find out whether this is an issue on the org-level REST API, or whether the CLI is not using the org-level APIs in the expected way.
It’s related to how the APIs behave when the user is no longer a member of the org, and thus the codespace is no longer visible to the user. When the CLI is making the call to
https://api.github.com/orgs/snowfall-travel/members/USER/codespaces?per_page=100, that endpoint currently only shows codespaces that are visible to the USER, which it’s not because they have been removed. That’s different behavior from both the non-user-scoped org-level list endpoint as well as the delete endpoint which allows you to see and act on codespaces that are not visible to the end user.I would expect the
https://api.github.com/orgs/snowfall-travel/members/USER/codespaces?per_page=100endpoint to work similarly to the other org APIs and show codespaces even if they are not currently visible to the end user. But I also think the CLI doesn’t need to make that API call in this scenario since it already knows the codespace name, org, and user. The CLI should be able to directly call the delete endpoint which should work.Thanks for the extra details. Just to double check because you used
USERandUSERNAMEinterchangeably, this is just you manually redacting the name of the candidate right?I’m sure we’ll be able to figure this out for you.
Sorry @ciaranevans I mean
GH_DEBUG=api!Hey @williammartin !
Sure, let me get those for you.
Well, I am one of the Org owners and this user was invited to one repo for a technical interview, I’ve been able to delete others codespaces in this scenario till now.