Skip to content

gh project edit fails: variable $query used but not declared in UpdateProjectV2 #12756

@KamelOtmani

Description

@KamelOtmani

Describe the bug

gh project edit fails with a GraphQL error on user-owned ProjectV2:

Variable $query is used by UpdateProjectV2 but not declared (mutation UpdateProjectV2.updateProjectV2.projectV2.items.query)

This appears to be a CLI-side query construction bug (not user input), because the same update works via direct GraphQL mutation using gh api graphql.

Steps to reproduce

  1. Authenticate with project scopes.
  2. Ensure a user-owned project exists (example: project number 2 under owner KamelOtmani).
  3. Run:
gh project edit 2 --owner KamelOtmani --description "repro-test desc"

Also reproducible with other flags:

gh project edit 2 --owner KamelOtmani --title "Project"
gh project edit 2 --owner KamelOtmani --readme "hello"

Expected behavior

Project metadata updates successfully.

Actual behavior

Command fails with:

GraphQL: Variable $query is used by UpdateProjectV2 but not declared (mutation UpdateProjectV2.updateProjectV2.projectV2.items.query)

Debug output excerpt

With GH_DEBUG=api:

  • CLI sends mutation UpdateProjectV2(...) whose selection includes:
    items(first: $firstItems, after: $afterItems, query: $query)
  • But variables only include:
    {"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{...}}
  • No $query variable is declared/passed.

Server responds with variableNotDefined for query.

Workaround

Direct GraphQL mutation works:

gh api graphql \
  -f query='mutation($projectId:ID!,$shortDescription:String!){ updateProjectV2(input:{projectId:$projectId, shortDescription:$shortDescription}) { projectV2 { id title shortDescription } } }' \
  -f projectId='PVT_kwHOAJ4Xxs4BP7US' \
  -f shortDescription='repro via api works'

Environment

  • gh version 2.87.2 (2026-02-20)
  • Linux (x64)
  • Auth scopes include project

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-projectrelating to the gh project commandpriority-2Affects more than a few users but doesn't prevent core functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions