gastownhall/beads · error
failed to get repos config: %w
Error message
failed to get repos config: %w
What it means
AddRepo starts by reading the current repos configuration from config.yaml via GetReposFromYAML. If that read/parse fails, the error is wrapped as "failed to get repos config", so the underlying cause (read error or YAML parse error) is chained with %w.
Source
Thrown at internal/config/repos.go:203
additionalNode.Content = append(additionalNode.Content,
&yaml.Node{Kind: yaml.ScalarNode, Value: path, Style: yaml.DoubleQuotedStyle},
)
}
node.Content = append(node.Content,
&yaml.Node{Kind: yaml.ScalarNode, Value: "additional"},
additionalNode,
)
}
return node
}
// AddRepo adds a repository to the repos.additional list in config.yaml
// If primary is not set, it defaults to "."
func AddRepo(configPath, repoPath string) error {
repos, err := GetReposFromYAML(configPath)
if err != nil {
return fmt.Errorf("failed to get repos config: %w", err)
}
// Set primary to "." if not already set (standard multi-repo convention)
if repos.Primary == "" {
repos.Primary = "."
}
// Check if repo already exists
for _, existing := range repos.Additional {
if existing == repoPath {
return fmt.Errorf("repository already configured: %s", repoPath)
}
}
// Add the new repo
repos.Additional = append(repos.Additional, repoPath)
return SetReposInYAML(configPath, repos)View on GitHub (pinned to 71377f2769)
Solutions
- Unwrap the chained error (errors.Unwrap / %v of err) to see the root cause
- Validate config.yaml syntax with yamllint and fix the offending line
- Restore a known-good config.yaml (backup or git checkout)
- Verify you are passing the correct configPath to AddRepo
Example fix
// before
AddRepo("config.yaml", "/repo") // hides root cause
// after
if err := AddRepo("config.yaml", "/repo"); err != nil {
log.Printf("cause: %v", errors.Unwrap(err))
} Defensive patterns
Strategy: try-catch
Validate before calling
data, _ := os.ReadFile(configPath)
var probe map[string]any
if err := yaml.Unmarshal(data, &probe); err != nil {
return fmt.Errorf("pre-check: config.yaml unparseable: %w", err)
} Try / catch
if err := AddRepo(cfgPath, repoPath); err != nil {
if strings.Contains(err.Error(), "failed to get repos config") {
log.Printf("root cause: %v", errors.Unwrap(err))
}
return err
} Prevention
- Validate YAML before every programmatic edit
- Keep config.yaml in git to recover from corruption
- Avoid concurrent writers to config.yaml (use a lock or serialize commands)
- Verify configPath resolution (env, HOME) before calls
When it happens
Trigger: GetReposFromYAML(configPath) returns an error — invalid YAML in config.yaml, unreadable file, or a malformed repos section — and AddRepo propagates it.
Common situations: A hand-edited config.yaml with a syntax error; a partially written config from a previous crashed run; wrong configPath passed to AddRepo.
Related errors
- persist sync.remote to config.yaml: %w
- failed to persist sync.remote to config.yaml: %w
- failed to persist sync.remote to config.yaml: %v
- failed to configure hydration: %w
- error reading config file: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/0b3415c6e8864898.
Report an issue: GitHub.