{"record":{"id":"eb1b08113a558c64","repo":"chenhg5/cc-connect","slug":"global-provider-q-not-found","errorCode":null,"errorMessage":"global provider %q not found","messagePattern":"global provider %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":1288,"sourceCode":"\tfor k, gp := range cfg.Providers {\n\t\tif gp.Name != providerName || k >= len(globalStarts) {\n\t\t\tcontinue\n\t\t}\n\t\tgstart := globalStarts[k]\n\t\tgend := len(lines) - 1\n\t\tif k+1 < len(globalStarts) {\n\t\t\tgend = globalStarts[k+1] - 1\n\t\t}\n\t\tfor j := gstart + 1; j <= gend; j++ {\n\t\t\tif isAnyTableHeader(lines[j]) {\n\t\t\t\tgend = j - 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tlines = upsertTomlStringKey(lines, gstart+1, gend, key, value)\n\t\treturn writeRawConfig(joinConfigLines(lines, hadTrailing))\n\t}\n\treturn fmt.Errorf(\"global provider %q not found\", providerName)\n}\n\n// SaveAgentModel persists the selected default model for a project's agent.\n// It uses surgical text editing to preserve comments and unknown fields.\nfunc SaveAgentModel(projectName, model string) error {\n\tconfigMu.Lock()\n\tdefer configMu.Unlock()\n\treturn patchProjectAgentOption(projectName, \"model\", model)\n}\n\n// AddProviderToConfig adds a provider to a project's agent config and saves.\nfunc AddProviderToConfig(projectName string, provider ProviderConfig) error {\n\tconfigMu.Lock()\n\tdefer configMu.Unlock()\n\tif ConfigPath == \"\" {\n\t\treturn fmt.Errorf(\"config path not set\")\n\t}\n\tdata, err := os.ReadFile(ConfigPath)","sourceCodeStart":1270,"sourceCodeEnd":1306,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L1270-L1306","documentation":"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.","triggerScenarios":"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.","commonSituations":"Deleting a [[providers]] block without cleaning provider_refs; renaming a global provider; sharing a config template where the referenced global provider was stripped.","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"],"exampleFix":"// before\nprovider_refs = [\"glm\"]  # no [providers] block for glm\n// after\nprovider_refs = [\"kimi\"]","handlingStrategy":"validation","validationCode":"refs := proj.Agent.ProviderRefs\nglobals := map[string]bool{}\nfor _, g := range cfg.Providers { globals[g.Name] = true }\nfor _, r := range refs {\n\tif !globals[r] { return fmt.Errorf(\"dangling provider_ref %q\", r) }\n}","typeGuard":null,"tryCatchPattern":"if err := config.SaveProviderModel(proj, prov, model); err != nil {\n\tif strings.Contains(err.Error(), \"global provider\") {\n\t\t// remove the dangling ref or restore the [[providers]] block\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["config","provider","dangling-ref"],"backgroundTag":"record-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}