From e0b613d5b19ebf937f3bbe22414f8506636d186f Mon Sep 17 00:00:00 2001 From: Andrey Taranov <86911+antigremlin@users.noreply.github.com> Date: Thu, 8 Jan 2026 04:45:58 +0000 Subject: [PATCH] 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 --- internal/storage/sqlite/batch_ops.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/storage/sqlite/batch_ops.go b/internal/storage/sqlite/batch_ops.go index 69e31ee5..a3e13631 100644 --- a/internal/storage/sqlite/batch_ops.go +++ b/internal/storage/sqlite/batch_ops.go @@ -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 }