{"record":{"id":"086b1cece6cae515","repo":"alibaba/open-code-review","slug":"load-config-w-086b1c","errorCode":null,"errorMessage":"load config: %w","messagePattern":"load config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/provider_cmd.go","lineNumber":27,"sourceCode":"\t\"net/url\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\ttea \"charm.land/bubbletea/v2\"\n\n\t\"github.com/alibaba/open-code-review/internal/llm\"\n)\n\nfunc runConfigProvider() error {\n\tconfigPath, err := defaultConfigPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfg, err := loadOrCreateConfig(configPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load config: %w\", err)\n\t}\n\n\tm := newProviderTUI(cfg, configPath)\n\tp := tea.NewProgram(m)\n\tfinalModel, err := p.Run()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"TUI error: %w\", err)\n\t}\n\n\tfinal := finalModel.(providerTUIModel)\n\n\tif !final.confirmed {\n\t\t// TUI persists changes during the session; Esc only abandons the final\n\t\t// provider/API-key confirmation step.\n\t\tprintWizardCancelled(final.savedInSession, \"Configuration changes\")\n\t\treturn nil\n\t}\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/provider_cmd.go#L9-L45","documentation":"This error wraps a failure from loadOrCreateConfig when starting the interactive provider configuration command (`ocr config provider`). The config file could not be read or created — typically a permissions problem, an invalid path, or a malformed existing file that fails parsing.","triggerScenarios":"Running `ocr config provider` when loadOrCreateConfig(configPath) errors: unwritable directory for a new config, unreadable existing config, or a corrupt/malformed config file.","commonSituations":"Running under a user without write access to $HOME; read-only CI containers; hand-edited config with broken syntax; wrong --config path pointing into a non-existent directory.","solutions":["Check the config path exists and is readable/writable: `ls -l <path>`; fix permissions with chmod/chown.","If the file is corrupt, fix the syntax or delete it and let the TUI recreate a fresh config.","Pass an explicit writable --config path if the default location is not writable.","Read the wrapped cause after 'load config:' for the precise filesystem or parse error."],"exampleFix":"// before\n$ ocr config provider\nload config: open /root/.ocr/config.toml: permission denied\n// after\n$ chmod u+rw /root/.ocr/config.toml && ocr config provider","handlingStrategy":"validation","validationCode":"dir := filepath.Dir(configPath)\nif err := os.MkdirAll(dir, 0o755); err != nil { return err }\nif fi, err := os.Stat(configPath); err == nil && fi.Mode().Perm()&0o600 == 0 {\n    os.Chmod(configPath, 0o600)\n}","typeGuard":null,"tryCatchPattern":"cfg, err := loadOrCreateConfig(configPath)\nif err != nil {\n    return fmt.Errorf(\"load config: %w\", err)\n}","preventionTips":["Ensure the config directory exists and is writable by the running user.","Avoid running config commands as a different user than the one who owns $HOME.","Fix config syntax immediately after failed hand edits rather than retrying."],"tags":["config","cli","filesystem","permissions"],"backgroundTag":"config-load-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}