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:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"strings"
|
||||
|
||||
"github.com/steveyegge/beads/internal/config"
|
||||
)
|
||||
|
||||
// SetConfig sets a configuration value
|
||||
@@ -147,16 +149,27 @@ func (s *SQLiteStorage) GetCustomStatuses(ctx context.Context) ([]string, error)
|
||||
|
||||
// GetCustomTypes retrieves the list of custom issue types from config.
|
||||
// Custom types are stored as comma-separated values in the "types.custom" config key.
|
||||
// If the database doesn't have custom types configured, falls back to config.yaml.
|
||||
// This fallback is essential during bd init when the database is being created
|
||||
// but auto-import needs to validate issues with custom types (GH#1225).
|
||||
// Returns an empty slice if no custom types are configured.
|
||||
func (s *SQLiteStorage) GetCustomTypes(ctx context.Context) ([]string, error) {
|
||||
value, err := s.GetConfig(ctx, CustomTypeConfigKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if value == "" {
|
||||
return nil, nil
|
||||
if value != "" {
|
||||
return parseCommaSeparatedList(value), nil
|
||||
}
|
||||
return parseCommaSeparatedList(value), nil
|
||||
|
||||
// Fallback to config.yaml when database doesn't have types.custom set.
|
||||
// This allows auto-import during bd init to work with custom types
|
||||
// defined in config.yaml before they're persisted to the database.
|
||||
if yamlTypes := config.GetCustomTypesFromYAML(); len(yamlTypes) > 0 {
|
||||
return yamlTypes, nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// parseCommaSeparatedList splits a comma-separated string into a slice of trimmed entries.
|
||||
|
||||
Reference in New Issue
Block a user