{"record":{"id":"bdd2ffe91321744e","repo":"alibaba/open-code-review","slug":"load-app-config-w","errorCode":null,"errorMessage":"load app config: %w","messagePattern":"load app config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/shared.go","lineNumber":227,"sourceCode":"// from the user's default config path (applying the configured language to\n// tpl — defaulting when the config file is absent), resolves the LLM\n// endpoint (honoring resolveOpts), and\n// returns the runtime bundle. tpl is mutated in place.\nfunc loadLLMRuntime(tpl *template.Template, toolConfigPath string, resolveOpts llm.ResolveOptions) (*llmRuntime, error) {\n\ttoolEntries, err := toolsconfig.Load(toolConfigPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load tools: %w\", err)\n\t}\n\tplanToolDefs := agent.BuildToolDefs(toolEntries, true)\n\tmainToolDefs := agent.BuildToolDefs(toolEntries, false)\n\n\tcfgPath, err := defaultConfigPath()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tappCfg, err := LoadAppConfig(cfgPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load app config: %w\", err)\n\t}\n\t// Apply the language directive even when the config file is missing\n\t// (upstream #fix: ApplyLanguage with empty lang falls back to default).\n\tvar lang string\n\tif appCfg != nil {\n\t\tlang = appCfg.Language\n\t}\n\ttpl.ApplyLanguage(lang)\n\n\tep, err := llm.ResolveEndpointWithOptions(cfgPath, resolveOpts)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolve LLM endpoint: %w\", err)\n\t}\n\n\tretryCollector := newRetryCollector()\n\n\treturn &llmRuntime{\n\t\tClient:         llm.NewLLMClient(ep, retryCollector),","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/shared.go#L209-L245","documentation":"loadLLMRuntime reads the application config from defaultConfigPath() via LoadAppConfig and wraps failures as `load app config: %w`. A missing config file is tolerated (appCfg may be nil and defaults apply), so this error means the file exists but is invalid or unreadable — bad syntax, unknown fields, wrong types.","triggerScenarios":"ocr review/scan startup when the user's config file (at the default config path) exists but fails to parse or validate; file unreadable due to permissions; hand-edited JSON/YAML with a syntax error.","commonSituations":"Manual edits leaving a trailing comma or wrong indentation; a `language` value of the wrong type; config written by another tool version with an incompatible field; file locked or owned by another user.","solutions":["Fix the syntax/type error at the reported line in the config file","Temporarily move the config aside to confirm it is the cause, then re-add settings incrementally","Fix permissions on the config file and its parent directory","Regenerate a fresh default config and re-apply your settings"],"exampleFix":"// before (~/.config/ocr/config.json)\n{ \"language\": \"en\", }   // trailing comma\n// after\n{ \"language\": \"en\" }","handlingStrategy":"validation","validationCode":"data, err := os.ReadFile(cfgPath)\nif err != nil {\n\treturn err\n}\nvar raw map[string]any\nif err := json.Unmarshal(data, &raw); err != nil {\n\treturn fmt.Errorf(\"config %s is not valid JSON: %w\", cfgPath, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n\t// config exists but is broken; move it aside and start from defaults\n\tos.Rename(cfgPath, cfgPath+\".bak\")\n\treturn retryWithDefaults()\n}","preventionTips":["Validate the config with a JSON/YAML linter before saving","Change one setting at a time and re-run","Keep the config owned and writable only by your user"],"tags":["go","config","json"],"backgroundTag":"config-parse-error","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}