chenhg5/cc-connect · error

reload config: %w

Error message

reload config: %w

What it means

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.

Source

Thrown at cmd/cc-connect/main.go:1729

	case "error":
		logLevel = slog.LevelError
	default:
		logLevel = slog.LevelInfo
	}
	if w == nil {
		w = os.Stdout
	}
	slog.SetDefault(slog.New(slog.NewTextHandler(w, &slog.HandlerOptions{
		Level: logLevel,
	})))
}

// reloadConfig re-reads config.toml and applies hot-reloadable settings
// (display, providers, commands) to the given engine.
func reloadConfig(configPath, projName string, engine *core.Engine) (*core.ConfigReloadResult, error) {
	cfg, err := config.Load(configPath)
	if err != nil {
		return nil, fmt.Errorf("reload config: %w", err)
	}

	result := &core.ConfigReloadResult{}

	// Re-apply process-global hot-reloadable settings.
	if globalAPIServer != nil {
		globalAPIServer.SetMaxAttachmentSize(resolveMaxAttachmentSize(cfg))
	}

	// Find the matching project
	var proj *config.ProjectConfig
	for i := range cfg.Projects {
		if cfg.Projects[i].Name == projName {
			proj = &cfg.Projects[i]
			break
		}
	}
	if proj == nil {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Run the file through a TOML validator to find syntax errors.
  2. Confirm configPath still exists and is readable by the daemon user.
  3. Fix the syntax error and re-trigger the reload.
  4. Keep the daemon's --config path argument consistent with the file actually edited.

Example fix

# before (broken TOML)
[display]
quiet = true
[display   # unclosed table
# after (valid TOML)
[display]
quiet = true
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(configPath); err != nil {
    return fmt.Errorf("config file missing: %w", err)
}
if err := toml.ValidateFile(configPath); err != nil {
    return fmt.Errorf("config invalid: %w", err)
}

Try / catch

result, err := reloadConfig(configPath, projName, engine)
if err != nil {
    slog.Warn("hot reload aborted; keeping previous config", "err", err)
    return previousResult, nil // or surface err to the caller
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/ac8161f7d78b2a3c. Report an issue: GitHub.