{"record":{"id":"a3da3948a9ab3155","repo":"charmbracelet/crush","slug":"provider-with-id-s-not-found-in-known-providers","errorCode":null,"errorMessage":"provider with ID %s not found in known providers","messagePattern":"provider with ID (.+?) not found in known providers","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/store.go","lineNumber":625,"sourceCode":"\t\t\t\tfoundProvider = &p\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif foundProvider != nil {\n\t\t\tproviderConfig = ProviderConfig{\n\t\t\t\tID:           providerID,\n\t\t\t\tName:         foundProvider.Name,\n\t\t\t\tBaseURL:      foundProvider.APIEndpoint,\n\t\t\t\tType:         foundProvider.Type,\n\t\t\t\tDisable:      false,\n\t\t\t\tExtraHeaders: make(map[string]string),\n\t\t\t\tExtraParams:  make(map[string]string),\n\t\t\t\tModels:       foundProvider.Models,\n\t\t\t}\n\t\t\tsetKeyOrToken()\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"provider with ID %s not found in known providers\", providerID)\n\t\t}\n\t\tcfg.Providers.Set(providerID, providerConfig)\n\t}\n\n\t// After authenticating with Hyper, re-fetch the provider catalog so\n\t// the latest models are available without restarting.\n\tif providerID == \"hyper\" {\n\t\tif refetchErr := s.RefetchHyperProvider(context.Background()); refetchErr != nil {\n\t\t\tslog.Warn(\"Failed to refetch Hyper provider after auth\", \"error\", refetchErr)\n\t\t}\n\t}\n\treturn nil\n}\n\n// RefreshOAuthToken refreshes the OAuth token for the given provider.\n//\n// Providers like Hyper rotate refresh tokens: each exchange consumes the\n// caller's refresh token, issues a new pair, and revokes the old one. If","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/config/store.go#L607-L643","documentation":"After saving a credential, SetProviderAPIKey needs to attach the credential to an in-memory provider config. If the provider ID is neither already configured nor found among the known (catwalk) providers, the store refuses to build a provider entry and returns this error.","triggerScenarios":"Calling SetProviderAPIKey with a providerID that is misspelled, uses different casing, or refers to a custom/unknown provider that is absent from both cfg.Providers and the knownProviders catalog fetched from catwalk.","commonSituations":"Typo in the provider ID passed after `crush login <provider>`; a provider recently removed/renamed in the upstream catalog; custom provider defined only in a scope not being written; stale cached catalog missing a brand-new provider.","solutions":["Check the exact provider ID against the known catalog (crush models list) and fix the spelling/case","Refresh the provider catalog so a newly added provider appears","Define the provider explicitly in the config first, then set its API key","Fall back to editing the config file manually to add providers.<id> with api_key"],"exampleFix":"// before\nerr := store.SetProviderAPIKey(ctx, scope, \"anthropic\", key) // actual ID: \"anthropic\"\n// assume typo: \"Anthropic\"\n// after\nids := []string{}\nfor _, p := range store.KnownProviders() { ids = append(ids, string(p.ID)) }\nif !slices.Contains(ids, providerID) {\n    return fmt.Errorf(\"unknown provider %q; known: %v\", providerID, ids)\n}\nerr := store.SetProviderAPIKey(ctx, scope, providerID, key)","handlingStrategy":"validation","validationCode":"known := store.KnownProviders()\nids := make([]string, 0, len(known))\nfor _, p := range known { ids = append(ids, string(p.ID)) }\nif _, cfgd := store.Config().Providers.Get(providerID); !cfgd && !slices.Contains(ids, providerID) {\n    return fmt.Errorf(\"provider %q unknown; valid IDs: %v\", providerID, ids)\n}","typeGuard":"func providerExists(store *config.ConfigStore, id string) bool {\n    if _, ok := store.Config().Providers.Get(id); ok { return true }\n    for _, p := range store.KnownProviders() {\n        if string(p.ID) == id { return true }\n    }\n    return false\n}","tryCatchPattern":"if err := store.SetProviderAPIKey(ctx, scope, providerID, key); err != nil {\n    if strings.Contains(err.Error(), \"not found in known providers\") {\n        return fmt.Errorf(\"%w — run 'crush models' to list valid provider IDs\", err)\n    }\n    return err\n}","preventionTips":["Copy provider IDs exactly from the catalog output (case-sensitive)","Refresh the provider catalog before authenticating against newly added providers","Validate IDs against KnownProviders() before calling SetProviderAPIKey","Define custom providers in config before assigning credentials to them"],"tags":["provider-id","validation","configuration"],"backgroundTag":"unknown-provider-id","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}