You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"unknown owner type" Error Message on gh project Bad Auth Token #8885
Hmm, both the pr and project commands uses a github.com/cli/go-gh/v2 Graphql client to their respective GraphQL requests. The pr command calls (*GraphQLClient).DoWithContext(). The API auth error error is a *ghAPI.HTTPError and is handled here:
For a non 200 HTTP response code, the shurcooL-graphql client returns a generic error rather than the custom *ghAPI.GraphQLError type, so it doesn't match the error targets in handleResponse
A similar error unknown owner type can be observed with a valid token, but with insufficient scopes, e.g. running gh project field-list <project number> --owner <owner> with a token containing repo scope but missing read:org and read:project scope. Setting GH_DEBUG=api gives a more detailed error trace from the GitHub API, which reveals the missing read:org scope first.
The error message when just the read:project scope is missing is more meaningful: error: your authentication token is missing required scopes [read:project] -- this would be really helpful for all such missing scopes!
Activity
Innu38 commentedon Apr 10, 2024
Innu38 commentedon Apr 10, 2024
harveysanders commentedon Apr 11, 2024
Hmm, both the
prandprojectcommands uses agithub.com/cli/go-gh/v2Graphql client to their respective GraphQL requests. Theprcommand calls(*GraphQLClient).DoWithContext(). The API auth error error is a*ghAPI.HTTPErrorand is handled here:cli/api/client.go
Lines 166 to 175 in 88a7e52
With the
projectcommand, the GraphQL request is made with(*GraphQLClient).QueryWithContext(), which uses agithub.com/cli/shurcooL-graphqlclient. The API auth error is handled here:https://github.com/shurcooL/graphql/blob/main/graphql.go#L77-L80
For a non
200HTTP response code, the shurcooL-graphql client returns a genericerrorrather than the custom*ghAPI.GraphQLErrortype, so it doesn't match the error targets inhandleResponsecli/api/client.go
Lines 161 to 185 in 88a7e52
As such, the error doesn't match the final
api.GraphQLErrortarget check where the request was originally made in(Client).OwnerIDAndTypecli/pkg/cmd/project/shared/queries/queries.go
Lines 1016 to 1028 in 88a7e52
So we're left with
"unknown owner type"error message.The simplest fix may be to wrap the GraphQL error with the "unknown owner type" error (or another message altogether):
That would result in a more informative, (maybe ugly) error message:
adityasharad commentedon Mar 12, 2025
A similar error
unknown owner typecan be observed with a valid token, but with insufficient scopes, e.g. runninggh project field-list <project number> --owner <owner>with a token containingreposcope but missingread:organdread:projectscope. SettingGH_DEBUG=apigives a more detailed error trace from the GitHub API, which reveals the missingread:orgscope first.The error message when just the
read:projectscope is missing is more meaningful:error: your authentication token is missing required scopes [read:project]-- this would be really helpful for all such missing scopes!(testing with 2.67.0 on macOS Sequoia)