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