{"record":{"id":"45b8c28eb311097e","repo":"chenhg5/cc-connect","slug":"provider-q-not-found-in-project-q","errorCode":null,"errorMessage":"provider %q not found in project %q","messagePattern":"provider %q not found in project %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":1260,"sourceCode":"\tprojSpan := spans[projectIdx]\n\n\tfor j, prov := range cfg.Projects[projectIdx].Agent.Providers {\n\t\tif prov.Name == providerName {\n\t\t\tif j < len(projSpan.agentProviders) {\n\t\t\t\tps := projSpan.agentProviders[j]\n\t\t\t\tlines = upsertTomlStringKey(lines, ps.start+1, ps.end, \"model\", model)\n\t\t\t\treturn writeRawConfig(joinConfigLines(lines, hadTrailing))\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, ref := range cfg.Projects[projectIdx].Agent.ProviderRefs {\n\t\tif ref == providerName {\n\t\t\treturn patchGlobalProviderField(lines, hadTrailing, cfg, providerName, \"model\", model)\n\t\t}\n\t}\n\treturn fmt.Errorf(\"provider %q not found in project %q\", providerName, projectName)\n}\n\nfunc patchGlobalProviderField(lines []string, hadTrailing bool, cfg *Config, providerName, key, value string) error {\n\tglobalStarts := make([]int, 0, 4)\n\tfor i := range lines {\n\t\tif matchTableHeader(lines[i], \"[[providers]]\") {\n\t\t\tglobalStarts = append(globalStarts, i)\n\t\t}\n\t}\n\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}","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L1242-L1278","documentation":"Provider model patcher: providerName was not found among the project's agent.providers names, nor among its provider_refs pointing at the global providers table, so no TOML key can be located to write the new model value and the update is aborted without modifying the file.","triggerScenarios":"Calling SaveProviderModel(project, providerName, model) where providerName matches no cfg.Projects[idx].Agent.Providers[i].Name and is absent from Agent.ProviderRefs.","commonSituations":"Referring to a provider defined globally but never added to provider_refs; renaming a provider block but saving with the old name; typo in the provider name in a script.","solutions":["Add the global provider's name to the project's provider_refs so it can be patched via [[providers]]","Or define the provider inline under the project's agent.providers","Correct the providerName argument to match an existing provider exactly","Verify available names from the parsed config before saving"],"exampleFix":"// before\nprovider_refs = [\"kimi\"]\n// after (provider \"glm\" now resolvable)\nprovider_refs = [\"kimi\", \"glm\"]","handlingStrategy":"validation","validationCode":"known := map[string]bool{}\nfor _, p := range proj.Agent.Providers { known[p.Name] = true }\nfor _, r := range proj.Agent.ProviderRefs { known[r] = true }\nif !known[providerName] { return fmt.Errorf(\"provider %q unknown\", providerName) }","typeGuard":null,"tryCatchPattern":"if err := config.SaveProviderModel(proj, prov, model); err != nil {\n\tif strings.Contains(err.Error(), \"not found in project\") {\n\t\t// offer to add the provider or fix the name\n\t}\n\treturn err\n}","preventionTips":["Keep provider names in a shared constant/enum used by scripts","After renaming a provider, update all save/model-switch references","Verify against the UI/doctor's provider list before saving"],"tags":["config","provider","not-found"],"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"}