cli: Issue commands do not work with non-classic Projects

Describe the bug

A clear and concise description of what the bug is. Include version by typing gh --version.

Steps to reproduce the behavior

  1. Create a new Project (Beta) in your org
  2. Add an issue to a repo in the org
  3. gh issue edit ISSUE --add-project PROJECTNAME

Expected vs actual behavior

Expected: the issue is added to project board Actual: ‘PROJECTNAME’ not found

Logs

‘PROJECTNAME’ not found

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 40
  • Comments: 22 (9 by maintainers)

Most upvoted comments

In the interim, it might be helpful for the error message to explicitly call this out by saying: “Note: If your project name references a non-classic project, please be aware that the gh CLI currently only support classic projects”.

@matthewmayer Thanks for writing in, right now gh does not support the new beta projects feature, it is likely that we will implement something in the future once it is no longer beta. I am going to change this from a bug to a feature request to reflect that.

I can confirm this works - I had to do a brew upgrade gh and run the gh auth refresh -s project and it now works like a charm with Projects v2. Thanks @samcoe !

Thanks everyone for their ideas and contributions to this feature. I just merged in the PR that adds support for ProjectsV2 in issue create, issue edit, pr create, and pr edit commands. Due to how ProjectsV2 was developed it is required to add the project scope to your auth token in order to use them in gh. Please use gh auth refresh -s project to add that scope. If your token does not have the project scope those commands will continue to work the same as they previously did and still have support for classic projects.

There is an open PR that adds this feature that you are all welcome to try out! Due to the size of added code, our team didn’t yet time to make an in-depth review, but we will get to it. Thanks for your patience

If someone wants to take this on before our team gets to this: we currently add projects to an issue here: https://github.com/cli/cli/blob/95b1e7f74ed9c43328e4ba0b7f20bd1d6d7028c4/pkg/cmd/pr/shared/params.go#L107-L111

That API only works with projects-old (the current Projects) and not with projects-next (sometimes called “Projects (beta)”). To add an issue to a project-next, one would have to switch to using the GraphQL mutation addProjectNextItem. But, for that we would have to resolve the project to a GraphQL ID. We do that for projects-old here: https://github.com/cli/cli/blob/95b1e7f74ed9c43328e4ba0b7f20bd1d6d7028c4/api/queries_repo.go#L1001-L1006

I guess we would have to add separate queries to fetch all projects-next for the repo and for the org so that they too can be resolved from title to GraphQL ID.

https://docs.github.com/en/issues/trying-out-the-new-projects-experience/using-the-api-to-manage-projects


In the meantime, you can add issues to a Projects-next with a manual GraphQL mutation:

gh api -f project="$project_id" -f item="$issue_id" -f query='
mutation AddToProject($project: ID!, $item: ID!) {
	addProjectNextItem(input: { projectId: $project, contentId: $item }) {
		projectNextItem {
			id
		}
	}
}'

Sorry for the confusion as I was not clear in my previous comment, now that the PR has been merged it will be available with the next release.

I’ve opened a PR trying to address this issue: https://github.com/cli/cli/pull/6043. Looking forward to your feedback.

Which version of gh is required for this to work? I upgraded to the latest 2.21.2 but it doesnt seem to work.

Any updates? Do commands now work with non-classic Projects?

@mislav Where the issue list command is currently lacking I’ve found is when using the --json output, the projectCards item is always just an empty array even if the issue is assigned to a project with attributes set on it. Glancing at the issue that fixed the issue create and such, it looks like projectItems may need to be added as a supported field.

I’ll open an issue for this