chenhg5/cc-connect · error
alias %q not found
Error message
alias %q not found
What it means
RemoveAlias returns this after scanning cfg.Aliases and finding no entry whose Name matches the requested name. No file was modified. It is a lookup failure on the persisted alias list, distinct from file/parse errors.
Source
Thrown at config/config.go:1785
data, err := os.ReadFile(ConfigPath)
if err != nil {
return fmt.Errorf("read config: %w", err)
}
cfg := &Config{}
if err := toml.Unmarshal(data, cfg); err != nil {
return fmt.Errorf("parse config: %w", err)
}
found := false
var remaining []AliasConfig
for _, a := range cfg.Aliases {
if a.Name == name {
found = true
} else {
remaining = append(remaining, a)
}
}
if !found {
return fmt.Errorf("alias %q not found", name)
}
cfg.Aliases = remaining
return saveConfig(cfg)
}
// SaveDisplayConfig persists the display settings to the config file.
// Uses surgical text editing to preserve comments and unknown fields.
func SaveDisplayConfig(mode *string, thinkingMessages *bool, thinkingMaxLen, toolMaxLen *int, toolMessages *bool) error {
configMu.Lock()
defer configMu.Unlock()
if mode != nil {
if err := patchSectionField("display", "mode", quoteTomlString(*mode)); err != nil {
return err
}
}
if thinkingMessages != nil {
if err := patchSectionField("display", "thinking_messages", fmt.Sprintf("%t", *thinkingMessages)); err != nil {
return errView on GitHub (pinned to 4000b2338a)
Solutions
- List current aliases (the app's alias list command or read cfg.Aliases) to see exact names.
- Match the name exactly, including case and quoting, since comparison is exact string equality.
- Ignore/handle the error if the goal is idempotent deletion ('remove if exists').
- Check you are editing the same config file (ConfigPath) that contains the alias.
Example fix
// before
err := config.RemoveAlias("MyAlias") // stored as "myalias" -> not found
// after
name := "myalias"
aliases, _ := config.ListAliases()
if slices.ContainsFunc(aliases, func(a config.AliasConfig) bool { return a.Name == name }) {
err = config.RemoveAlias(name)
} Defensive patterns
Strategy: fallback
Validate before calling
aliases, err := config.ListAliases()
exists := slices.ContainsFunc(aliases, func(a config.AliasConfig) bool { return a.Name == name }) Type guard
func aliasExists(name string) bool {
aliases, err := config.ListAliases()
if err != nil { return false }
return slices.ContainsFunc(aliases, func(a config.AliasConfig) bool { return a.Name == name })
} Try / catch
if err := config.RemoveAlias(name); err != nil {
if strings.Contains(err.Error(), "not found") {
log.Printf("alias %q already absent; treating as no-op", name)
return nil // idempotent delete
}
return err
} Prevention
- List aliases before removing to copy exact names.
- Treat removal as idempotent in scripts.
- Remember alias matching is case-sensitive exact equality.
- Verify you are operating on the same ConfigPath the alias was created in.
When it happens
Trigger: Calling config.RemoveAlias("name") where no alias with that exact Name exists in config.toml — typo, different casing, or the alias was already removed (aliases are matched with ==, so comparison is case-sensitive).
Common situations: Typing the alias name wrong; assuming aliases defined per-project or in another config file are global; double-invoking a remove command; stale UI showing an alias deleted by another session.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- cron project not found
- project %q not found in config
- provider %q not found in project %q
- command %q not found
- project %q not found
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/a309d7827ffdff76.
Report an issue: GitHub.