fix(sync): validate custom types in batch issue creation (#943)

Fix validation in batch issue creation to check custom types

Previously only validated custom statuses, causing sync to fail when JSONL
contained issues with types removed from core (agent, role, rig, convoy, slot).

Fixes: validation failed for issue: invalid issue type: agent
This commit is contained in:
Andrey Taranov
2026-01-08 04:45:58 +00:00
committed by GitHub
parent 7aa3e79649
commit e0b613d5b1

View File

@@ -16,13 +16,6 @@ func validateBatchIssues(issues []*types.Issue) error {
return validateBatchIssuesWithCustom(issues, nil, nil)
}
// validateBatchIssuesWithCustomStatuses validates all issues in a batch,
// allowing custom statuses in addition to built-in ones.
// Deprecated: Use validateBatchIssuesWithCustom instead.
func validateBatchIssuesWithCustomStatuses(issues []*types.Issue, customStatuses []string) error {
return validateBatchIssuesWithCustom(issues, customStatuses, nil)
}
// validateBatchIssuesWithCustom validates all issues in a batch,
// allowing custom statuses and types in addition to built-in ones.
func validateBatchIssuesWithCustom(issues []*types.Issue, customStatuses, customTypes []string) error {
@@ -257,14 +250,18 @@ func (s *SQLiteStorage) CreateIssuesWithFullOptions(ctx context.Context, issues
return nil
}
// Fetch custom statuses for validation
// Fetch custom statuses and types for validation
customStatuses, err := s.GetCustomStatuses(ctx)
if err != nil {
return fmt.Errorf("failed to get custom statuses: %w", err)
}
customTypes, err := s.GetCustomTypes(ctx)
if err != nil {
return fmt.Errorf("failed to get custom types: %w", err)
}
// Phase 1: Validate all issues first (fail-fast, with custom status support)
if err := validateBatchIssuesWithCustomStatuses(issues, customStatuses); err != nil {
// Phase 1: Validate all issues first (fail-fast, with custom status and type support)
if err := validateBatchIssuesWithCustom(issues, customStatuses, customTypes); err != nil {
return err
}