fix(dolt): add YAML fallback for custom types/statuses

When the Dolt database connection is temporarily unavailable (e.g.,
stale connection, server restart), GetCustomTypes() and GetCustomStatuses()
now fall back to reading from config.yaml instead of failing.

This matches the SQLite storage behavior and fixes the stop hook
failure where `gt costs record` would fail with "invalid issue type: event"
when the Dolt connection was broken.

The fallback is checked in two cases:
1. When database query returns an error
2. When database has no custom types/statuses configured

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
joe
2026-01-24 20:25:48 -08:00
committed by gastown/crew/joe
parent bf0bf7b156
commit f845bb1be3
2 changed files with 82 additions and 8 deletions

View File

@@ -721,3 +721,30 @@ func GetCustomTypesFromYAML() []string {
}
return result
}
// GetCustomStatusesFromYAML retrieves custom statuses from config.yaml.
// This is used as a fallback when the database doesn't have status.custom set yet
// or when the database connection is temporarily unavailable.
// Returns nil if no custom statuses are configured in config.yaml.
func GetCustomStatusesFromYAML() []string {
if v == nil {
return nil
}
// Try to get status.custom from viper (config.yaml or env var)
value := v.GetString("status.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
}