{"record":{"id":"4f5d117197bb306d","repo":"cli/cli","slug":"the-query-flag-is-not-supported-on-this-github","errorCode":null,"errorMessage":"the `--query` flag is not supported on this GitHub host","messagePattern":"the `--query` flag is not supported on this GitHub host","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/project/item-list/item_list.go","lineNumber":140,"sourceCode":"\n\tlistCmd.Flags().StringVar(&opts.owner, \"owner\", \"\", \"Login of the owner. Use \\\"@me\\\" for the current user\")\n\tlistCmd.Flags().StringVar(&opts.query, \"query\", \"\", `Filter items using the Projects filter syntax, e.g. \"assignee:octocat -status:Done\"`)\n\tlistCmd.Flags().StringArrayVar(&opts.fields, \"field\", nil, \"Name of a field to show as an extra column\")\n\tlistCmd.Flags().StringArrayVar(&opts.fieldIDs, \"field-id\", nil, \"ID of a field to show as an extra column\")\n\tcmdutil.AddFormatFlags(listCmd, &opts.exporter)\n\tlistCmd.Flags().IntVarP(&opts.limit, \"limit\", \"L\", queries.LimitDefault, \"Maximum number of items to fetch\")\n\n\treturn listCmd\n}\n\nfunc runList(config listConfig) error {\n\tif config.opts.query != \"\" {\n\t\tfeatures, err := config.detector.ProjectFeatures()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !features.ProjectItemQuery {\n\t\t\treturn fmt.Errorf(\"the `--query` flag is not supported on this GitHub host\")\n\t\t}\n\t}\n\n\tcanPrompt := config.io.CanPrompt()\n\towner, err := config.client.NewOwner(canPrompt, config.opts.owner)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// no need to fetch the project if we already have the number\n\tif config.opts.number == 0 {\n\t\tproject, err := config.client.NewProject(canPrompt, owner, config.opts.number, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tconfig.opts.number = project.Number\n\t}\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/project/item-list/item_list.go#L122-L158","documentation":"item-list's --query flag relies on a GitHub Projects feature (ProjectItemQuery) detected per host via config.detector.ProjectFeatures(). On hosts where the detector reports the capability absent (typically older GHES), passing --query fails fast with this message before fetching items.","triggerScenarios":"Running `gh project item-list <number> --query '...'` against a GHES instance whose version does not support project item querying via the newer API surface.","commonSituations":"Scripts developed against github.com then run against GHES, or after a GHES upgrade changed feature flags; users assume feature parity between github.com and GHES.","solutions":["Drop --query and filter client-side after fetching items (e.g. with --json and --jq on the local result)","Run the command against github.com if that is where the project lives (check -R/host config)","Upgrade GHES to a version supporting project item queries"],"exampleFix":"# before\ngh project item-list 1 --query 'status:\"Done\"'\n# after (client-side filter on GHES)\ngh project item-list 1 --json title,createdAt --jq '.[] | select(.title | contains(\"Done\"))'","handlingStrategy":"validation","validationCode":"if host != \"github.com\" && flagQuery != \"\" {\n    return errors.New(\"--query unsupported on this host; filter with --jq client-side\")\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"--query` flag is not supported\") {\n    return runWithoutQueryAndFilterLocally()\n}","preventionTips":["Feature-detect per host before using newer flags in portable scripts","Prefer --json plus --jq post-filtering for cross-host compatibility","Keep separate script paths for github.com and GHES"],"tags":["ghes","feature-detection","project","cli-usage"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}