{"record":{"id":"01f3d26527d839f7","repo":"cli/cli","slug":"resource-not-found-please-check-the-url","errorCode":null,"errorMessage":"resource not found, please check the URL","messagePattern":"resource not found, please check the URL","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/project/shared/queries/queries.go","lineNumber":1322,"sourceCode":"func (c *Client) IssueOrPullRequestID(rawURL string) (string, error) {\n\turi, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvariables := map[string]interface{}{\n\t\t\"url\": githubv4.URI{URL: uri},\n\t}\n\tvar query issueOrPullRequest\n\terr = c.doQueryWithProgressIndicator(\"GetIssueOrPullRequest\", &query, variables)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif query.Resource.Typename == \"Issue\" {\n\t\treturn query.Resource.Issue.ID, nil\n\t} else if query.Resource.Typename == \"PullRequest\" {\n\t\treturn query.Resource.PullRequest.ID, nil\n\t}\n\treturn \"\", errors.New(\"resource not found, please check the URL\")\n}\n\n// userProjects queries the $first projects of a user.\ntype userProjects struct {\n\tOwner struct {\n\t\tProjects struct {\n\t\t\tTotalCount int\n\t\t\tPageInfo   PageInfo\n\t\t\tNodes      []projectQueryWithoutQueryableItems\n\t\t} `graphql:\"projectsV2(first: $first, after: $after)\"`\n\t\tLogin string\n\t} `graphql:\"user(login: $login)\"`\n}\n\n// orgProjects queries the $first projects of an organization.\ntype orgProjects struct {\n\tOwner struct {\n\t\tProjects struct {","sourceCodeStart":1304,"sourceCodeEnd":1340,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/pkg/cmd/project/shared/queries/queries.go#L1304-L1340","documentation":"Returned by GetIssueOrPullRequest after a successful GraphQL query of a URL's resource node when the __typename is neither \"Issue\" nor \"PullRequest\". The command can only add issues and pull requests to projects, so any other resource type (discussion, discussion comment, or a null/empty typename from a bad URL) produces this error.","triggerScenarios":"Passing a URL to a project item-add command that resolves to something other than an Issue or PullRequest, e.g. a discussion URL (https://github.com/o/r/discussions/123), a repository URL, or a malformed URL that makes the GraphQL node resolve to an unexpected typename. The query itself succeeds, so only the typename dispatch fails.","commonSituations":"Users copy a discussions link instead of an issue link when running `gh project item-add`; passing a URL with a trailing slash or fragment that changes resolution; new GitHub resource types that the older gh version does not map.","solutions":["Check the URL points to an issue or pull request: https://github.com/OWNER/REPO/issues/N or .../pull/N","If you meant a discussion, note discussions are not supported by this code path; use the GraphQL API directly if you must add them","Print the typename in a debug run (GH_DEBUG=1) to see what the URL actually resolved to","Upgrade gh in case newer versions support more resource types"],"exampleFix":"// before\ngh project item-add 123 --url https://github.com/org/repo/discussions/45\n// after\ngh project item-add 123 --url https://github.com/org/repo/issues/45","handlingStrategy":"validation","validationCode":"// Accept only issue/PR URLs before calling the API:\nre := regexp.MustCompile(`^https://[^/]+/([^/]+)/([^/]+)/(issues|pull)/\\d+$`)\nif !re.MatchString(rawURL) {\n    return fmt.Errorf(\"%q is not an issue or pull request URL\", rawURL)\n}","typeGuard":null,"tryCatchPattern":"id, err := queries.GetIssueOrPullRequest(client, uri)\nif err != nil && strings.Contains(err.Error(), \"resource not found\") {\n    return fmt.Errorf(\"%s: only issue and pull request URLs can be added; check the URL\", uri)","preventionTips":["Validate the URL shape (issues/N or pull/N) in scripts before invoking gh project item-add","Never paste discussion or repository URLs where an issue URL is expected","Construct URLs from owner/repo/number in automation rather than scraping them from pages"],"tags":["projects","url-parsing","graphql","input-validation"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}