fix: load types.custom from config.yaml during init auto-import (GH#1225) (#1226)

During bd init, auto-import fails with "invalid issue type" errors even
when types.custom is defined in config.yaml. This happens because custom
types are read from the database, but the database is being created
during init and doesn't have the config set yet.

Changes:
- Add GetCustomTypesFromYAML() to internal/config/config.go to read
  types.custom from config.yaml via viper
- Modify GetCustomTypes() in sqlite/config.go to fallback to config.yaml
  when the database doesn't have types.custom configured
- Add tests for GetCustomTypesFromYAML()

This allows fresh clones with custom types defined in config.yaml (e.g.,
Gas Town types like molecule, gate, convoy, agent, event) to successfully
auto-import their JSONL during bd init.

Fixes GH#1225

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Brown
2026-01-21 01:34:22 -05:00
committed by GitHub
parent 63c2e50158
commit b7242a67d1
3 changed files with 144 additions and 3 deletions

View File

@@ -638,3 +638,30 @@ func NeedsJSONL() bool {
mode := GetSyncMode()
return mode == SyncModeGitPortable || mode == SyncModeRealtime || mode == SyncModeBeltAndSuspenders
}
// GetCustomTypesFromYAML retrieves custom issue types from config.yaml.
// This is used as a fallback when the database doesn't have types.custom set yet
// (e.g., during bd init auto-import before the database is fully configured).
// Returns nil if no custom types are configured in config.yaml.
func GetCustomTypesFromYAML() []string {
if v == nil {
return nil
}
// Try to get types.custom from viper (config.yaml or env var)
value := v.GetString("types.custom")
if value == "" {
return nil
}
// Parse comma-separated list
parts := strings.Split(value, ",")
result := make([]string, 0, len(parts))
for _, p := range parts {
trimmed := strings.TrimSpace(p)
if trimmed != "" {
result = append(result, trimmed)
}
}
return result
}