{"record":{"id":"d546dfdcb3714b0a","repo":"alibaba/open-code-review","slug":"load-config-w-d546df","errorCode":null,"errorMessage":"load config: %w","messagePattern":"load config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/llm_cmd.go","lineNumber":61,"sourceCode":"\tRun: func(cmd *cobra.Command, args []string) {\n\t\trunLLMProviders()\n\t},\n}\n\nfunc init() {\n\tllmCmd.AddCommand(llmTestCmd)\n\tllmCmd.AddCommand(llmProvidersCmd)\n}\n\nfunc runLLMTest() error {\n\tcfgPath, err := resolveConfigPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tappCfg, err := LoadAppConfig(cfgPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load config: %w\", err)\n\t}\n\n\tep, err := llm.ResolveEndpoint(cfgPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve LLM endpoint: %w\", err)\n\t}\n\n\ttask, err := testconnection.LoadDefault()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load test task config: %w\", err)\n\t}\n\tvar lang string\n\tif appCfg != nil {\n\t\tlang = appCfg.Language\n\t}\n\ttask.ApplyLanguage(lang)\n\n\ttimeout := 30 * time.Second","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/llm_cmd.go#L43-L79","documentation":"This error wraps any failure from LoadAppConfig when running `ocr llm test`. The config file at the resolved path either cannot be read, does not exist in an expected state, or fails parsing/validation. The %w wrapper preserves the underlying cause (parse error, permission error, etc.) for inspection with errors.Is/As.","triggerScenarios":"Running `ocr llm test` when LoadAppConfig(cfgPath) returns an error: the config file is missing required fields, contains invalid TOML/JSON syntax, or cannot be read from disk (permissions, wrong --config path).","commonSituations":"Hand-edited config with a syntax typo; pointing at a non-existent config path via --config; a config written by an older binary that fails current schema validation; read-permission problems after switching users or CI environments.","solutions":["Run `ocr config provider` (or check the resolved config path) and fix the file's syntax or missing fields.","Regenerate a valid config: `ocr init` or re-save via the provider TUI.","Verify the --config path exists and is readable: `ls -l <path>` and `cat <path>`.","Read the wrapped cause after 'load config:' in the message — it names the exact parse/validation failure."],"exampleFix":"// before (malformed config)\n[llm\nurl = \"https://api.example.com\"\n// after (valid TOML)\n[llm]\nurl = \"https://api.example.com\"","handlingStrategy":"validation","validationCode":"cfgPath := \"~/.ocr/config.toml\"\nif _, err := os.Stat(cfgPath); err != nil {\n    return fmt.Errorf(\"config file missing: %w\", err)\n}\nif _, err := LoadAppConfig(cfgPath); err != nil {\n    return fmt.Errorf(\"config invalid, fix before running llm test: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := LoadAppConfig(cfgPath); err != nil {\n    var parseErr *os.PathError\n    if errors.As(err, &parseErr) { /* fix path/permissions */ }\n    return fmt.Errorf(\"load config: %w\", err)\n}","preventionTips":["Validate config files with a linter or `ocr llm test` after every hand edit.","Never hand-edit config without backing it up first.","Use `ocr config provider` TUI instead of manual edits to keep the schema valid."],"tags":["config","cli","go"],"backgroundTag":"config-load-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}