chenhg5/cc-connect · error
config path not set
Error message
config path not set
What it means
SaveProviderModel refuses to run when the package-level ConfigPath variable has not been initialized. The function performs surgical text edits on the TOML file at ConfigPath, so without a path there is nothing to safely modify, and it fails rather than guessing a location.
Source
Thrown at config/config.go:1214
}
// SaveActiveProvider persists the active provider name for a project.
// It uses surgical text editing to preserve comments and unknown fields.
func SaveActiveProvider(projectName, providerName string) error {
configMu.Lock()
defer configMu.Unlock()
return patchProjectAgentOption(projectName, "provider", providerName)
}
// SaveProviderModel persists the selected model for a provider in a project.
// It first looks in the project's inline providers, then falls back to
// global [[providers]] if the provider is referenced via provider_refs.
// Uses surgical text editing to preserve comments and unknown fields.
func SaveProviderModel(projectName, providerName, model string) error {
configMu.Lock()
defer configMu.Unlock()
if ConfigPath == "" {
return fmt.Errorf("config path not set")
}
data, err := os.ReadFile(ConfigPath)
if err != nil {
return fmt.Errorf("read config: %w", err)
}
raw := string(data)
cfg := &Config{}
if err := toml.Unmarshal(data, cfg); err != nil {
return fmt.Errorf("parse config: %w", err)
}
projectIdx := -1
for i := range cfg.Projects {
if cfg.Projects[i].Name == projectName {
projectIdx = i
break
}
}View on GitHub (pinned to 4000b2338a)
Solutions
- Ensure LoadConfig (or explicit assignment to config.ConfigPath) runs before SaveProviderModel
- Pass/point the binary at a config file path (e.g. --config flag) at startup
- In tests, set config.ConfigPath to a temp file path in setup
Example fix
// before
config.SaveProviderModel("proj", "kimi", "model-x") // ConfigPath == ""
// after
config.ConfigPath = "/etc/cc-connect/config.toml"
config.SaveProviderModel("proj", "kimi", "model-x") Defensive patterns
Strategy: type-guard
Validate before calling
if config.ConfigPath == "" {
return errors.New("call LoadConfig or set config.ConfigPath first")
} Type guard
func canSave() bool { return config.ConfigPath != "" } Try / catch
if err := config.SaveProviderModel(p, prov, model); err != nil {
if err.Error() == "config path not set" {
config.LoadConfig(defaultPath) // then retry
}
return err
} Prevention
- Always run LoadConfig at process start before any save API
- Set ConfigPath in test setup with a temp file
- Centralize save calls behind a helper that ensures ConfigPath is set
When it happens
Trigger: Calling SaveProviderModel(project, provider, model) before LoadConfig/any code set config.ConfigPath — typically a library consumer invoking save APIs without loading config first, or a binary invoked with no config flag.
Common situations: Running a CLI subcommand that persists model changes without the --config flag; tests calling SaveProviderModel directly without setting ConfigPath; refactoring that removed the init call that sets ConfigPath.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
- qqbot: app_secret is required
- webex: token is required
- cron project not found
- attachment send is disabled by config
- VerifyRunAsUserCheap: runAsUser is empty
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/177758342e91d2ee.
Report an issue: GitHub.