Skip to content

Make centralized slash-command workflows emit non-required workflow_dispatch inputs#32480

Merged
pelikhan merged 15 commits into
mainfrom
copilot/aw-compiler-slash-commands
May 15, 2026
Merged

Make centralized slash-command workflows emit non-required workflow_dispatch inputs#32480
pelikhan merged 15 commits into
mainfrom
copilot/aw-compiler-slash-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Centralized slash-command workflows should not be blocked by workflow_dispatch input requirements, because they are invoked by the router, not manual callers. This change ensures compiled dispatch schemas are compatible with routed slash-command execution.

  • Compiler behavior (centralized slash commands)

    • Updated applyDefaults command-trigger path to normalize on.workflow_dispatch.inputs.*.required to false when on.slash_command.strategy: centralized is active.
    • Added setWorkflowDispatchInputsOptional(...) to safely no-op unless workflow_dispatch.inputs is a valid map.
  • Regression coverage

    • Added a focused compile test asserting a source input marked required: true is emitted as required: false in compiled lock YAML for centralized slash-command workflows.
if data.CommandCentralized {
    if len(data.CommandOtherEvents) > 0 {
        maps.Copy(commandEventsMap, data.CommandOtherEvents)
    }
    setWorkflowDispatchInputsOptional(commandEventsMap)
    if _, hasWorkflowDispatch := commandEventsMap["workflow_dispatch"]; !hasWorkflowDispatch {
        commandEventsMap["workflow_dispatch"] = nil
    }
}

Copilot AI and others added 2 commits May 15, 2026 21:28
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AW compiler required flag for slash commands Make centralized slash-command workflows emit non-required workflow_dispatch inputs May 15, 2026
Copilot AI requested a review from pelikhan May 15, 2026 21:30
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot the compiler should raise an error on required: true and slash_command/label_command

Copilot AI and others added 6 commits May 15, 2026 21:46
…gers

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review May 15, 2026 21:57
Copilot AI review requested due to automatic review settings May 15, 2026 21:57
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot recompile and fix agentic workflows with that error

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds compiler validation intended to address workflow_dispatch.inputs.*.required usage in workflows that use slash_command / label_command, along with new tests covering the resulting behavior.

Changes:

  • Added a new compiler validation step that rejects workflow_dispatch inputs marked required: true when slash_command or label_command triggers are present.
  • Added compile tests asserting compilation fails when required workflow_dispatch inputs are declared alongside centralized slash_command or label_command.
  • Introduced a new validation helper (validateCommandWorkflowDispatchInputs) to scan raw frontmatter for required dispatch inputs.
Show a summary per file
File Description
pkg/workflow/compiler_validators.go Invokes new validation step during compilation.
pkg/workflow/command_dispatch_validation.go Implements validation that errors on required: true workflow_dispatch inputs for command-trigger workflows.
pkg/workflow/slash_command_centralized_compile_test.go Adds regression tests that expect compilation to fail when required dispatch inputs are present.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines +188 to +192
// Validate workflow_dispatch required inputs with slash/label command triggers.
log.Printf("Validating workflow_dispatch input requirements for command triggers")
if err := validateCommandWorkflowDispatchInputs(workflowData); err != nil {
return formatCompilerError(markdownPath, "error", err.Error(), err)
}
Comment on lines +88 to +116
func TestSlashCommandRejectsRequiredDispatchInputs(t *testing.T) {
tmpDir := testutil.TempDir(t, "workflow-centralized-slash-dispatch-inputs-test")

markdownPath := filepath.Join(tmpDir, "scout.md")
content := `---
on:
slash_command:
name: scout
strategy: centralized
workflow_dispatch:
inputs:
topic:
description: "Research topic"
required: true
type: string
tools:
github:
allowed: [list_issues]
---

# Scout
`
require.NoError(t, os.WriteFile(markdownPath, []byte(content), 0644))

compiler := NewCompiler()
err := compiler.CompileWorkflow(markdownPath)
require.Error(t, err)
require.Contains(t, err.Error(), "on.workflow_dispatch.inputs.topic.required: true is not allowed when using slash_command")

Comment on lines +8 to +56
// validateCommandWorkflowDispatchInputs rejects required workflow_dispatch inputs when
// slash_command or label_command triggers are configured.
// Returns an error if any workflow_dispatch input has required: true.
func validateCommandWorkflowDispatchInputs(workflowData *WorkflowData) error {
if workflowData == nil || workflowData.RawFrontmatter == nil {
return nil
}

hasSlashCommand := len(workflowData.Command) > 0
hasLabelCommand := len(workflowData.LabelCommand) > 0
if !hasSlashCommand && !hasLabelCommand {
return nil
}

onMap, ok := workflowData.RawFrontmatter["on"].(map[string]any)
if !ok {
return nil
}

workflowDispatchMap, ok := onMap["workflow_dispatch"].(map[string]any)
if !ok {
return nil
}

inputsMap, ok := workflowDispatchMap["inputs"].(map[string]any)
if !ok {
return nil
}

for inputName, inputDef := range inputsMap {
inputDefMap, ok := inputDef.(map[string]any)
if !ok {
continue
}

required, ok := inputDefMap["required"].(bool)
if ok && required {
var triggerNames []string
if hasSlashCommand {
triggerNames = append(triggerNames, "slash_command")
}
if hasLabelCommand {
triggerNames = append(triggerNames, "label_command")
}
triggerNamesPhrase := strings.Join(triggerNames, " and ")

return fmt.Errorf(
"on.workflow_dispatch.inputs.%s.required: true is not allowed when using %s; set required: false",
inputName, triggerNamesPhrase,
Copilot AI and others added 2 commits May 15, 2026 22:01
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot the compiler should raise an error on required: true and slash_command/label_command

Implemented in a000647: the compiler now errors when on.workflow_dispatch.inputs.*.required: true is used with slash_command or label_command, and no longer rewrites those inputs to optional.

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all comments

Copilot AI and others added 2 commits May 15, 2026 22:09
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot recompile and fix agentic workflows with that error

Done in b93490c. I fixed the agentic workflows that hit the new validation (scout.md and pdf-summary.md now use workflow_dispatch.inputs.*.required: false) and recompiled workflows successfully, which also updated agentic_commands.yml routing and the corresponding lock files.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot review all comments

Reviewed all comments. The actionable items are addressed in a000647 (compiler now errors on required: true with slash_command/label_command) and b93490c (updated affected agentic workflows and recompiled lock files). I don’t see any remaining actionable comments for this PR.

@pelikhan pelikhan merged commit 276efd4 into main May 15, 2026
1 check failed
@pelikhan pelikhan deleted the copilot/aw-compiler-slash-commands branch May 15, 2026 22:24
Copilot stopped work on behalf of pelikhan due to an error May 15, 2026 22:24
github-actions Bot added a commit that referenced this pull request May 16, 2026
… @copilot mention default

- command-triggers.md: note that workflow_dispatch.inputs.required is normalized to false under strategy: centralized (from #32480)
- safe-outputs.md: note that @copilot is always preserved as a default allowed mention alias in add-comment (from #32487)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] AW compiler should have required: false for slash commands

3 participants