{"record":{"id":"0b3415c6e8864898","repo":"gastownhall/beads","slug":"failed-to-get-repos-config-w","errorCode":null,"errorMessage":"failed to get repos config: %w","messagePattern":"failed to get repos config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/repos.go","lineNumber":203,"sourceCode":"\t\t\tadditionalNode.Content = append(additionalNode.Content,\n\t\t\t\t&yaml.Node{Kind: yaml.ScalarNode, Value: path, Style: yaml.DoubleQuotedStyle},\n\t\t\t)\n\t\t}\n\t\tnode.Content = append(node.Content,\n\t\t\t&yaml.Node{Kind: yaml.ScalarNode, Value: \"additional\"},\n\t\t\tadditionalNode,\n\t\t)\n\t}\n\n\treturn node\n}\n\n// AddRepo adds a repository to the repos.additional list in config.yaml\n// If primary is not set, it defaults to \".\"\nfunc AddRepo(configPath, repoPath string) error {\n\trepos, err := GetReposFromYAML(configPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get repos config: %w\", err)\n\t}\n\n\t// Set primary to \".\" if not already set (standard multi-repo convention)\n\tif repos.Primary == \"\" {\n\t\trepos.Primary = \".\"\n\t}\n\n\t// Check if repo already exists\n\tfor _, existing := range repos.Additional {\n\t\tif existing == repoPath {\n\t\t\treturn fmt.Errorf(\"repository already configured: %s\", repoPath)\n\t\t}\n\t}\n\n\t// Add the new repo\n\trepos.Additional = append(repos.Additional, repoPath)\n\n\treturn SetReposInYAML(configPath, repos)","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/config/repos.go#L185-L221","documentation":"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.","triggerScenarios":"GetReposFromYAML(configPath) returns an error — invalid YAML in config.yaml, unreadable file, or a malformed repos section — and AddRepo propagates it.","commonSituations":"A hand-edited config.yaml with a syntax error; a partially written config from a previous crashed run; wrong configPath passed to AddRepo.","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"],"exampleFix":"// before\nAddRepo(\"config.yaml\", \"/repo\") // hides root cause\n// after\nif err := AddRepo(\"config.yaml\", \"/repo\"); err != nil {\n    log.Printf(\"cause: %v\", errors.Unwrap(err))\n}","handlingStrategy":"try-catch","validationCode":"data, _ := os.ReadFile(configPath)\nvar probe map[string]any\nif err := yaml.Unmarshal(data, &probe); err != nil {\n    return fmt.Errorf(\"pre-check: config.yaml unparseable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := AddRepo(cfgPath, repoPath); err != nil {\n    if strings.Contains(err.Error(), \"failed to get repos config\") {\n        log.Printf(\"root cause: %v\", errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["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"],"tags":["config","yaml","error-wrapping"],"backgroundTag":"config-file-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}