Skip to content

Commit 95a515e

Browse files
authored
Merge pull request cli#4087 from cli/graphql-error-fix
Fix unmarshalling GraphQL error type
2 parents 1007c1a + 90b7886 commit 95a515e

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

api/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ type graphQLResponse struct {
123123
// GraphQLError is a single error returned in a GraphQL response
124124
type GraphQLError struct {
125125
Type string
126-
Path []string
127126
Message string
127+
// Path []interface // mixed strings and numbers
128128
}
129129

130130
// GraphQLErrorResponse contains errors returned in a GraphQL response

pkg/cmd/secret/set/http.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,7 @@ func mapRepoNameToID(client *api.Client, host, orgName string, repositoryNames [
130130
DatabaseID int `json:"databaseId"`
131131
})
132132

133-
err := client.GraphQL(host, query, nil, &graphqlResult)
134-
135-
gqlErr, isGqlErr := err.(*api.GraphQLErrorResponse)
136-
if isGqlErr {
137-
for _, ge := range gqlErr.Errors {
138-
if ge.Type == "NOT_FOUND" {
139-
return nil, fmt.Errorf("could not find %s/%s", orgName, ge.Path[0])
140-
}
141-
}
142-
}
143-
if err != nil {
133+
if err := client.GraphQL(host, query, nil, &graphqlResult); err != nil {
144134
return nil, fmt.Errorf("failed to look up repositories: %w", err)
145135
}
146136

0 commit comments

Comments
 (0)