Skip to content

Commit 799f695

Browse files
authored
Fix SIGSEGV in changeset spec validation for imported changesets (#465)
1 parent 5bd42cd commit 799f695

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ All notable changes to `src-cli` are documented in this file.
1717

1818
### Fixed
1919

20+
- Importing changesets was broken in the previous release and caused a SIGSEGV error.
21+
2022
### Removed
2123

2224
## 3.24.4

internal/campaigns/service.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,12 @@ func (svc *Service) ValidateChangesetSpecs(repos []*graphql.Repository, specs []
425425

426426
byRepoAndBranch := make(map[string]map[string][]*ChangesetSpec)
427427
for _, spec := range specs {
428-
_, ok := byRepoAndBranch[spec.HeadRepository]
429-
if !ok {
428+
// We don't need to validate imported changesets, as they can
429+
// never have a critical branch name overlap.
430+
if spec.ExternalChangeset != nil {
431+
continue
432+
}
433+
if _, ok := byRepoAndBranch[spec.HeadRepository]; !ok {
430434
byRepoAndBranch[spec.HeadRepository] = make(map[string][]*ChangesetSpec)
431435
}
432436

internal/campaigns/service_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,16 @@ func TestService_ValidateChangesetSpecs(t *testing.T) {
537537
},
538538
},
539539

540+
"imported changeset": {
541+
repos: []*graphql.Repository{repo1},
542+
specs: []*ChangesetSpec{
543+
{ExternalChangeset: &ExternalChangeset{
544+
ExternalID: "123",
545+
}},
546+
},
547+
// This should not fail validation ever.
548+
},
549+
540550
"duplicate branches": {
541551
repos: []*graphql.Repository{repo1, repo2},
542552
specs: []*ChangesetSpec{

0 commit comments

Comments
 (0)