chenhg5/cc-connect · error
global provider %q not found
Error message
global provider %q not found
What it means
When the provider is handled through provider_refs, patchGlobalProviderField scans raw [[providers]] table headers in the file to find and edit the matching global provider. If no global [[providers]] block matches providerName, the ref is dangling and this error is returned, leaving the file untouched.
Source
Thrown at config/config.go:1288
for k, gp := range cfg.Providers {
if gp.Name != providerName || k >= len(globalStarts) {
continue
}
gstart := globalStarts[k]
gend := len(lines) - 1
if k+1 < len(globalStarts) {
gend = globalStarts[k+1] - 1
}
for j := gstart + 1; j <= gend; j++ {
if isAnyTableHeader(lines[j]) {
gend = j - 1
break
}
}
lines = upsertTomlStringKey(lines, gstart+1, gend, key, value)
return writeRawConfig(joinConfigLines(lines, hadTrailing))
}
return fmt.Errorf("global provider %q not found", providerName)
}
// SaveAgentModel persists the selected default model for a project's agent.
// It uses surgical text editing to preserve comments and unknown fields.
func SaveAgentModel(projectName, model string) error {
configMu.Lock()
defer configMu.Unlock()
return patchProjectAgentOption(projectName, "model", model)
}
// AddProviderToConfig adds a provider to a project's agent config and saves.
func AddProviderToConfig(projectName string, provider ProviderConfig) error {
configMu.Lock()
defer configMu.Unlock()
if ConfigPath == "" {
return fmt.Errorf("config path not set")
}
data, err := os.ReadFile(ConfigPath)View on GitHub (pinned to 4000b2338a)
Solutions
- Re-add the [[providers]] block with name = "<providerName>" so the ref resolves
- Remove the dangling entry from provider_refs in the project
- Fix the ref/provider name spelling so they match exactly
Example fix
// before provider_refs = ["glm"] # no [providers] block for glm // after provider_refs = ["kimi"]
Defensive patterns
Strategy: validation
Validate before calling
refs := proj.Agent.ProviderRefs
globals := map[string]bool{}
for _, g := range cfg.Providers { globals[g.Name] = true }
for _, r := range refs {
if !globals[r] { return fmt.Errorf("dangling provider_ref %q", r) }
} Try / catch
if err := config.SaveProviderModel(proj, prov, model); err != nil {
if strings.Contains(err.Error(), "global provider") {
// remove the dangling ref or restore the [[providers]] block
}
return err
} Prevention
- Never delete a [[providers]] block without pruning provider_refs
- Validate refs against global providers at config load time
- Comment each [[providers]] block with the projects that reference it
When it happens
Trigger: A project's provider_refs lists a name, SaveProviderModel delegates to patchGlobalProviderField, but no [[providers]] table with name = providerName exists in the file — the ref points at a removed or never-defined global provider.
Common situations: Deleting a [[providers]] block without cleaning provider_refs; renaming a global provider; sharing a config template where the referenced global provider was stripped.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- codex: resolve codex home: %w
- provider %q not found in project %q
- cron project not found
- attachment send is disabled by config
- VerifyRunAsUserCheap: runAsUser is empty
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/eb1b08113a558c64.
Report an issue: GitHub.