{"record":{"id":"ac8161f7d78b2a3c","repo":"chenhg5/cc-connect","slug":"reload-config-w","errorCode":null,"errorMessage":"reload config: %w","messagePattern":"reload config: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/main.go","lineNumber":1729,"sourceCode":"\tcase \"error\":\n\t\tlogLevel = slog.LevelError\n\tdefault:\n\t\tlogLevel = slog.LevelInfo\n\t}\n\tif w == nil {\n\t\tw = os.Stdout\n\t}\n\tslog.SetDefault(slog.New(slog.NewTextHandler(w, &slog.HandlerOptions{\n\t\tLevel: logLevel,\n\t})))\n}\n\n// reloadConfig re-reads config.toml and applies hot-reloadable settings\n// (display, providers, commands) to the given engine.\nfunc reloadConfig(configPath, projName string, engine *core.Engine) (*core.ConfigReloadResult, error) {\n\tcfg, err := config.Load(configPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reload config: %w\", err)\n\t}\n\n\tresult := &core.ConfigReloadResult{}\n\n\t// Re-apply process-global hot-reloadable settings.\n\tif globalAPIServer != nil {\n\t\tglobalAPIServer.SetMaxAttachmentSize(resolveMaxAttachmentSize(cfg))\n\t}\n\n\t// Find the matching project\n\tvar proj *config.ProjectConfig\n\tfor i := range cfg.Projects {\n\t\tif cfg.Projects[i].Name == projName {\n\t\t\tproj = &cfg.Projects[i]\n\t\t\tbreak\n\t\t}\n\t}\n\tif proj == nil {","sourceCodeStart":1711,"sourceCodeEnd":1747,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/main.go#L1711-L1747","documentation":"reloadConfig wraps failures from config.Load(configPath) when re-reading config.toml during a hot reload. It means the TOML file could not be loaded — parse error, missing file, or read failure — so the new settings cannot be applied to the engine. The original Load error is preserved via %w.","triggerScenarios":"Calling reloadConfig (from the web/API reload handler) after the config file was deleted, renamed, contains TOML syntax errors, or was saved with an unreadable encoding/permissions.","commonSituations":"Editor left invalid TOML on disk (unclosed string/table); config file moved while the daemon runs; partial write during save; permission change on config.toml.","solutions":["Run the file through a TOML validator to find syntax errors.","Confirm configPath still exists and is readable by the daemon user.","Fix the syntax error and re-trigger the reload.","Keep the daemon's --config path argument consistent with the file actually edited."],"exampleFix":"# before (broken TOML)\n[display]\nquiet = true\n[display   # unclosed table\n# after (valid TOML)\n[display]\nquiet = true","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(configPath); err != nil {\n    return fmt.Errorf(\"config file missing: %w\", err)\n}\nif err := toml.ValidateFile(configPath); err != nil {\n    return fmt.Errorf(\"config invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"result, err := reloadConfig(configPath, projName, engine)\nif err != nil {\n    slog.Warn(\"hot reload aborted; keeping previous config\", \"err\", err)\n    return previousResult, nil // or surface err to the caller\n}","preventionTips":["Validate config.toml with a TOML parser after every edit before triggering reload.","Keep the daemon running from a stable config path and edit that exact file.","Write configs atomically (temp file + rename) to avoid partial reads.","Back up the last known-good config so you can restore quickly."],"tags":["go","config","toml","hot-reload"],"backgroundTag":"config-file-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}