Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions pkg/workflow/label_trigger_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ func TestLabelTriggerIntegrationSimple(t *testing.T) {
t.Errorf("issues.types = %v, want [labeled]", types)
}

// Check names
names, ok := issues["names"].([]string)
// Check names (stored as []any by expandLabelTriggerShorthand)
namesRaw, ok := issues["names"].([]any)
if !ok {
t.Fatalf("issues.names is not a string array")
t.Fatalf("issues.names is not a []any array")
}
var names []string
for _, n := range namesRaw {
if s, isStr := n.(string); isStr {
names = append(names, s)
}
Comment on lines +47 to +51
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion from []any to []string silently skips non-string entries. That can allow the test to pass even if the underlying data contains unexpected non-string values (e.g., ["bug","enhancement",123] would still pass). Consider failing the test if any element is not a string, and also assert that len(namesRaw) matches the expected count so extra elements aren't ignored.

This issue also appears on line 163 of the same file.

Suggested change
var names []string
for _, n := range namesRaw {
if s, isStr := n.(string); isStr {
names = append(names, s)
}
if len(namesRaw) != 2 {
t.Fatalf("issues.names raw length = %d, want 2; raw=%v", len(namesRaw), namesRaw)
}
var names []string
for i, n := range namesRaw {
s, isStr := n.(string)
if !isStr {
t.Fatalf("issues.names[%d] is not a string: %T (%v)", i, n, n)
}
names = append(names, s)

Copilot uses AI. Check for mistakes.
}
if len(names) != 2 || names[0] != "bug" || names[1] != "enhancement" {
t.Errorf("issues.names = %v, want [bug enhancement]", names)
Expand Down Expand Up @@ -149,10 +155,16 @@ func TestLabelTriggerIntegrationPullRequest(t *testing.T) {
t.Errorf("pull_request.types = %v, want [labeled]", types)
}

// Check names
names, ok := pr["names"].([]string)
// Check names (stored as []any by expandLabelTriggerShorthand)
namesRaw, ok := pr["names"].([]any)
if !ok {
t.Fatalf("pull_request.names is not a string array")
t.Fatalf("pull_request.names is not a []any array")
}
var names []string
for _, n := range namesRaw {
if s, isStr := n.(string); isStr {
names = append(names, s)
}
}
if len(names) != 2 || names[0] != "needs-review" || names[1] != "approved" {
t.Errorf("pull_request.names = %v, want [needs-review approved]", names)
Expand Down