{"record":{"id":"682c5c3be56263fc","repo":"chenhg5/cc-connect","slug":"read-config-file-w","errorCode":null,"errorMessage":"read config file: %w","messagePattern":"read config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":623,"sourceCode":"// CommandConfig defines a user-customizable slash command that expands a prompt template or executes a shell command.\ntype CommandConfig struct {\n\tName        string `toml:\"name\"`\n\tDescription string `toml:\"description\"`\n\tPrompt      string `toml:\"prompt\"`   // prompt template (mutually exclusive with Exec)\n\tExec        string `toml:\"exec\"`     // shell command to execute (mutually exclusive with Prompt)\n\tWorkDir     string `toml:\"work_dir\"` // optional: working directory for exec command\n}\n\ntype LogConfig struct {\n\tLevel string `toml:\"level\"`\n}\n\n// load parses, env-resolves, and wires providers in the config file but does\n// NOT validate — callers must call validate() or validatePermissive() themselves.\nfunc load(path string) (*Config, error) {\n\tdata, err := os.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read config file: %w\", err)\n\t}\n\tcfg := &Config{Log: LogConfig{Level: \"info\"}}\n\tif err := toml.Unmarshal(data, cfg); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse config: %w\", err)\n\t}\n\tresolveEnvInConfig(cfg)\n\tif cfg.DataDir == \"\" {\n\t\tif home, err := os.UserHomeDir(); err == nil {\n\t\t\tcfg.DataDir = filepath.Join(home, \".cc-connect\")\n\t\t} else {\n\t\t\tcfg.DataDir = \".cc-connect\"\n\t\t}\n\t}\n\tcfg.AttachmentSend = strings.ToLower(strings.TrimSpace(cfg.AttachmentSend))\n\tif cfg.AttachmentSend == \"\" {\n\t\tcfg.AttachmentSend = \"on\"\n\t}\n\tcfg.ResolveProviderRefs()","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L605-L641","documentation":"config.load wraps os.ReadFile failure on the config.toml path (missing file, permission denied, I/O error). This is the first step of every config load, so the error aborts startup or the command that needed the config.","triggerScenarios":"Thrown at config/config.go:623 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the --config path exists and is readable by the running user","Run cc-connect init to generate a config file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}