Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/credentials/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package credentials

import (
"strings"
)

func IsCredentialsNotFoundError(err error) bool {
if err == nil {
return false
}
return strings.Contains(err.Error(), "credentials not found in native keychain")
}
3 changes: 1 addition & 2 deletions pkg/credentials/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/docker/cli/cli/config/credentials"
"github.com/docker/cli/cli/config/types"
"github.com/docker/docker-credential-helpers/client"
credentials2 "github.com/docker/docker-credential-helpers/credentials"
"github.com/gptscript-ai/gptscript/pkg/config"
"golang.org/x/exp/maps"
)
Expand Down Expand Up @@ -50,7 +49,7 @@ func (s Store) Get(_ context.Context, toolName string) (*Credential, bool, error
for _, c := range s.credCtxs {
auth, err := store.Get(toolNameWithCtx(toolName, c))
if err != nil {
if credentials2.IsErrCredentialsNotFound(err) {
if IsCredentialsNotFoundError(err) {
continue
}
return nil, false, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/credentials/toolstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (h *toolCredentialStore) Erase(serverAddress string) error {

func (h *toolCredentialStore) Get(serverAddress string) (types.AuthConfig, error) {
creds, err := client.Get(h.program, serverAddress)
if credentials2.IsErrCredentialsNotFound(err) {
if IsCredentialsNotFoundError(err) {
return h.file.Get(serverAddress)
} else if err != nil {
return types.AuthConfig{}, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
} else if credentialAlias != "" {
c, exists, err = r.credStore.Get(callCtx.Ctx, credentialAlias)
if err != nil {
return nil, fmt.Errorf("failed to get credentials for tool %s: %w", credentialAlias, err)
return nil, fmt.Errorf("failed to get credential %s: %w", credentialAlias, err)
}
}

Expand Down