Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions pkg/workflow/lint/output_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func checkAllowedLabels(ctx context.Context, input Input) ([]Diagnostic, error)
return diagnostics, errors.Join(append(failures, err)...)
}
path := "safe-outputs." + handler
// `handler: true` or `false` only enables or disables the handler; it has no allowed-labels.
if _, isBool := outputs[handler].(bool); isBool {
continue
}
config, err := policyMapping(outputs[handler], path)
if err != nil {
failures = append(failures, err)
Expand Down
20 changes: 20 additions & 0 deletions pkg/workflow/lint/policy_conversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ func TestAllowedLabelsRule(t *testing.T) {
}
}

func TestAllowedLabelsRuleSkipsBooleanHandlers(t *testing.T) {
// smoke-claude-sub-agents disables issue creation with `create-issue: false`; a boolean
// handler has no allowed-labels to check and must not be reported as malformed.
for _, handler := range []string{"create-issue", "create-discussion", "update-discussion", "create-pull-request"} {
other := "create-discussion"
if handler == other {
other = "create-pull-request"
}
for _, value := range []string{"true", "false"} {
input := policyTestInput(t, "safe-outputs:\n "+handler+": "+value+"\n "+other+":\n allowed-labels: ['*']")
runner, err := New(AllowedLabelsRule())
require.NoError(t, err)
diagnostics, err := runner.Run(context.Background(), input)
require.NoError(t, err, handler+": "+value)
require.Len(t, diagnostics, 1, "other handlers are still checked")
assert.Equal(t, "safe-outputs."+other+".allowed-labels", diagnostics[0].Path)
}
}
}

func TestPushTargetRule(t *testing.T) {
for _, tt := range []struct {
fields string
Expand Down
Loading