{"record":{"id":"4588f12bef9ed139","repo":"cli/cli","slug":"error-fetching-organization-teams-w","errorCode":null,"errorMessage":"error fetching organization teams: %w","messagePattern":"error fetching organization teams: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/queries_repo.go","lineNumber":1027,"sourceCode":"\t\t} else {\n\t\t\t// Not using Actors, fetch legacy assignable users.\n\t\t\tg.Go(func() error {\n\t\t\t\tusers, err := RepoAssignableUsers(client, repo)\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = fmt.Errorf(\"error fetching assignable users: %w\", err)\n\t\t\t\t}\n\t\t\t\tresult.AssignableUsers = users\n\t\t\t\treturn err\n\t\t\t})\n\t\t}\n\t}\n\n\tif input.Reviewers && input.TeamReviewers {\n\t\tg.Go(func() error {\n\t\t\tteams, err := OrganizationTeams(client, repo)\n\t\t\t// TODO: better detection of non-org repos\n\t\t\tif err != nil && !strings.Contains(err.Error(), errorResolvingOrganization) {\n\t\t\t\terr = fmt.Errorf(\"error fetching organization teams: %w\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tresult.Teams = teams\n\t\t\treturn nil\n\t\t})\n\t}\n\n\tif input.Reviewers {\n\t\tg.Go(func() error {\n\t\t\tlogin, err := CurrentLoginName(client, repo.RepoHost())\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"error fetching current login: %w\", err)\n\t\t\t}\n\t\t\tresult.CurrentLogin = login\n\t\t\treturn err\n\t\t})\n\t}\n","sourceCodeStart":1009,"sourceCodeEnd":1045,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/api/queries_repo.go#L1009-L1045","documentation":"RepoMetadata fetches organization teams in parallel when Reviewers and TeamReviewers inputs are set. OrganizationTeams is called and any error whose message does NOT contain errorResolvingOrganization (i.e. the repo genuinely belongs to an org but the query failed) is wrapped with this message and fails the errgroup. Non-org repos are tolerated: the 'Could not resolve to an Organization' error is swallowed so team review is silently skipped for personal repos.","triggerScenarios":"'gh pr create --reviewer @org/team-slug' on an org-owned repo when the organization teams GraphQL query fails: insufficient org token permissions (org read blocked by SSO), org enforcing OAuth app restrictions, or network failure. Not triggered for user-owned repos because the resolving-organization error is filtered.","commonSituations":"SAML SSO not authorized for the token on the org; GitHub App installations lacking org member/team read; org owners restricting third-party access; typos in team slug are NOT this error (that is a later not-found error).","solutions":["Authorize the token for SAML SSO: 'gh auth refresh -h github.com -s read:org' (or click Authorize on the org SSO page)","If using a GitHub App token, grant it read access to org teams or reinstall with permissions","Verify org allows your OAuth app access under org settings -> Third-party Access","Check network/proxy reachability of the API host"],"exampleFix":"# before (token not SSO-authorized)\ngh pr create --reviewer @acme/core --fill\n# -> error fetching organization teams: ...\n\n# after\ngh auth refresh -h github.com -s read:org\n# complete SSO authorization in browser, then\ngh pr create --reviewer @acme/core --fill","handlingStrategy":"validation","validationCode":"// Skip team reviewers when the repo has no org, avoiding the query entirely\nif !isOrgRepo(repo) {\n    input.TeamReviewers = false\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"organization teams\") && isSamlError(err) {\n        return fmt.Errorf(\"authorize this token for SAML SSO on the org, then retry: %w\", err)\n    }\n    return err\n}","preventionTips":["Run 'gh auth refresh -s read:org' and complete SSO before using @org/team reviewers","Grant GitHub Apps org member/team read permissions","For personal repos, drop team reviewer flags to avoid the org query path"],"tags":["github-api","teams","sso","permissions","organization"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}