fix(update): accept custom types from types.custom config (GH#hq-8hif1z)
Some checks failed
CI / Check version consistency (push) Successful in 4s
CI / Check for .beads changes (push) Has been skipped
CI / Test (ubuntu-latest) (push) Failing after 6m29s
CI / Lint (push) Failing after 2m25s
CI / Test Nix Flake (push) Failing after 51s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (Windows - smoke) (push) Has been cancelled

The `bd update --type` command was rejecting custom types (like role, agent,
rig) even when configured via types.custom. The issue was that type validation
used IsValid() which only checks the 5 core types, ignoring custom types.

Changes:
- CLI (update.go): Use IsValidWithCustom() with types from config
- Storage (validators.go): Add validateIssueTypeWithCustom() function
- Storage (queries.go, transaction.go): Fetch and pass custom types

The error message now dynamically shows all valid types including custom ones.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jasper
2026-01-24 15:07:17 -08:00
committed by John Ogle
parent d9bf159af1
commit b762fa05f0
4 changed files with 83 additions and 12 deletions

View File

@@ -37,11 +37,17 @@ func validateStatusWithCustom(value interface{}, customStatuses []string) error
return nil
}
// validateIssueType validates an issue type value
// validateIssueType validates an issue type value (built-in types only)
func validateIssueType(value interface{}) error {
return validateIssueTypeWithCustom(value, nil)
}
// validateIssueTypeWithCustom validates an issue type value, allowing custom types.
// Custom types are configured via bd config set types.custom "type1,type2,..."
func validateIssueTypeWithCustom(value interface{}, customTypes []string) error {
if issueType, ok := value.(string); ok {
// Normalize first to support aliases like "enhancement" -> "feature"
if !types.IssueType(issueType).Normalize().IsValid() {
if !types.IssueType(issueType).Normalize().IsValidWithCustom(customTypes) {
return fmt.Errorf("invalid issue type: %s", issueType)
}
}
@@ -77,18 +83,29 @@ var fieldValidators = map[string]func(interface{}) error{
"estimated_minutes": validateEstimatedMinutes,
}
// validateFieldUpdate validates a field update value (built-in statuses only)
// validateFieldUpdate validates a field update value (built-in statuses and types only)
func validateFieldUpdate(key string, value interface{}) error {
return validateFieldUpdateWithCustomStatuses(key, value, nil)
return validateFieldUpdateWithCustom(key, value, nil, nil)
}
// validateFieldUpdateWithCustomStatuses validates a field update value,
// allowing custom statuses for status field validation.
// DEPRECATED: Use validateFieldUpdateWithCustom instead which also handles custom types.
func validateFieldUpdateWithCustomStatuses(key string, value interface{}, customStatuses []string) error {
return validateFieldUpdateWithCustom(key, value, customStatuses, nil)
}
// validateFieldUpdateWithCustom validates a field update value,
// allowing custom statuses and custom types for validation (GH#hq-8hif1z).
func validateFieldUpdateWithCustom(key string, value interface{}, customStatuses, customTypes []string) error {
// Special handling for status field to support custom statuses
if key == "status" {
return validateStatusWithCustom(value, customStatuses)
}
// Special handling for issue_type field to support custom types
if key == "issue_type" {
return validateIssueTypeWithCustom(value, customTypes)
}
if validator, ok := fieldValidators[key]; ok {
return validator(value)
}