{"record":{"id":"7baa52f3aeb1003d","repo":"chenhg5/cc-connect","slug":"project-q-not-found-in-config-7baa52","errorCode":null,"errorMessage":"project %q not found in config","messagePattern":"project %q not found in config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":1234,"sourceCode":"\tdata, err := os.ReadFile(ConfigPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read config: %w\", err)\n\t}\n\traw := string(data)\n\tcfg := &Config{}\n\tif err := toml.Unmarshal(data, cfg); err != nil {\n\t\treturn fmt.Errorf(\"parse config: %w\", err)\n\t}\n\n\tprojectIdx := -1\n\tfor i := range cfg.Projects {\n\t\tif cfg.Projects[i].Name == projectName {\n\t\t\tprojectIdx = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif projectIdx < 0 {\n\t\treturn fmt.Errorf(\"project %q not found in config\", projectName)\n\t}\n\n\tlines, hadTrailing := splitConfigLines(raw)\n\tspans := buildRawProjectSpans(lines)\n\tif projectIdx >= len(spans) {\n\t\treturn fmt.Errorf(\"project %q located in parsed config but not raw file\", projectName)\n\t}\n\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}","sourceCodeStart":1216,"sourceCodeEnd":1252,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L1216-L1252","documentation":"After parsing succeeds, SaveProviderModel searches cfg.Projects for a project matching projectName. If none matches, it returns this error — the save target simply does not exist in the config file, so nothing is written.","triggerScenarios":"Calling SaveProviderModel with a projectName string that equals no cfg.Projects[i].Name in config.toml — misspelled name, project removed, or wrong project identifier (e.g. path vs display name).","commonSituations":"Scripting model switches with a stale/hard-coded project name after renaming the project; passing a directory path where only the config's project name works; project deleted by another session.","solutions":["Run the app's project list (or grep name = under [[projects]]) and use the exact name","Fix the typo in projectName at the call site","Add the missing [[projects]] entry if it should exist"],"exampleFix":"// before\nconfig.SaveProviderModel(\"my-project\", \"kimi\", \"m1\") // actual name: \"myproject\"\n// after\nconfig.SaveProviderModel(\"myproject\", \"kimi\", \"m1\")","handlingStrategy":"validation","validationCode":"for _, pr := range cfg.Projects {\n\tif pr.Name == projectName { return nil }\n}\nreturn fmt.Errorf(\"unknown project %q\", projectName)","typeGuard":null,"tryCatchPattern":"if err := config.SaveProviderModel(name, prov, model); err != nil {\n\tif strings.Contains(err.Error(), \"not found in config\") {\n\t\t// list valid project names for the user\n\t}\n\treturn err\n}","preventionTips":["Read project names from the config at runtime instead of hard-coding","Match names exactly (no paths or display names)","Add autocomplete/verification in scripts before saving"],"tags":["config","project","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"}