{"record":{"id":"230c240c6f07b797","repo":"alibaba/open-code-review","slug":"custom-provider-q-not-found","errorCode":null,"errorMessage":"custom provider %q not found","messagePattern":"custom provider %q not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":292,"sourceCode":"\n\tdelete(cfg.MCPServers, name)\n\tif len(cfg.MCPServers) == 0 {\n\t\tcfg.MCPServers = nil\n\t}\n\n\tif err := saveConfig(configPath, cfg); err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"Deleted MCP server %q.\\n\", name)\n\treturn nil\n}\n\n// deleteCustomProvider removes a custom provider from cfg in memory.\n// Returns true if the deleted provider was the active one.\nfunc deleteCustomProvider(cfg *Config, name string) (bool, error) {\n\tif cfg.CustomProviders == nil {\n\t\treturn false, fmt.Errorf(\"custom provider %q not found\", name)\n\t}\n\tif _, exists := cfg.CustomProviders[name]; !exists {\n\t\treturn false, fmt.Errorf(\"custom provider %q not found\", name)\n\t}\n\n\twasActive := cfg.Provider == name\n\tdelete(cfg.CustomProviders, name)\n\tif len(cfg.CustomProviders) == 0 {\n\t\tcfg.CustomProviders = nil\n\t}\n\n\tif wasActive {\n\t\tcfg.Provider = \"\"\n\t\tcfg.Model = \"\"\n\t}\n\n\treturn wasActive, nil\n}","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L274-L310","documentation":"deleteCustomProvider returns this error when cfg.CustomProviders is nil, meaning no customProviders section exists in the config. Called from unsetCustomProvider during 'ocr config unset provider <name>'; the deletion aborts before any mutation.","triggerScenarios":"Running 'ocr config unset provider <name>' on a config that has never defined any custom provider (no customProviders key in the JSON).","commonSituations":"Attempting to unset a built-in provider name (only custom providers are deletable) on a config without custom providers; fresh install; script assuming providers exist.","solutions":["Verify the name refers to a custom provider you previously added with 'ocr config set provider <name> ...'.","List existing custom providers in the config file before unsetting.","If the goal is to disable provider-based config entirely, run 'ocr config unset provider' without a name instead."],"exampleFix":"// before: no custom providers configured\n$ ocr config unset provider openai\nerror: custom provider \"openai\" not found\n\n// after: unset active provider instead\n$ ocr config unset provider","handlingStrategy":"validation","validationCode":"cfg, _ := LoadAppConfig(configPath)\nif cfg == nil || cfg.CustomProviders == nil {\n    return fmt.Errorf(\"no custom providers configured; nothing to unset\")\n}","typeGuard":"func hasCustomProviders(cfg *Config) bool {\n    return cfg != nil && cfg.CustomProviders != nil\n}","tryCatchPattern":"if err := unsetCustomProvider(configPath, name); err != nil && strings.Contains(err.Error(), \"not found\") {\n    return nil // already absent\n}","preventionTips":["Remember only custom providers can be unset by name; use bare 'ocr config unset provider' to clear the active provider.","List custom providers in the config before deleting.","Make cleanup scripts idempotent."],"tags":["go","cli","config","provider"],"backgroundTag":"custom-provider-not-found","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}