Skip to content

fix: default github.repos to all when omitted from guard policy#21718

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-invalid-guard-policy
Mar 19, 2026
Merged

fix: default github.repos to all when omitted from guard policy#21718
pelikhan merged 3 commits intomainfrom
copilot/fix-invalid-guard-policy

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Specifying only min-integrity under tools.github without a repos field incorrectly raised a hard validation error, despite repos: all being the obvious intent when no restriction is needed.

Changes

  • tools_validation.go: When repos is absent but min-integrity is set, silently default repos to "all" instead of returning an error
  • tools_validation_test.go: Updated test case from "should error" to "should succeed with defaulted repos"
  • scratchpad/: Updated documentation to reflect that min-integrity is the only required field; repos defaults to "all"
  • pkg/cli/workflows/test-guard-policy-min-integrity-only.md: Added workflow fixture demonstrating min-integrity without repos compiles cleanly
  • pkg/cli/compile_guard_policy_test.go: Added unit tests covering all guard policy compilation scenarios (min-integrity-only, explicit repos=all, repos=public, repos array, and repos-only-without-min-integrity)

Before / After

# Previously required both fields — now this is valid:
tools:
  github:
    min-integrity: none

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix invalid guard policy requirement for single repo fix: default github.repos to all when omitted from guard policy Mar 19, 2026
Copilot AI requested a review from pelikhan March 19, 2026 03:19
@pelikhan
Copy link
Contributor

@copilot add workflow integration tests in pkg/cli/workflows

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

Copilot AI commented Mar 19, 2026

@copilot add workflow integration tests in pkg/cli/workflows

Added in b37ea93:

  • pkg/cli/workflows/test-guard-policy-min-integrity-only.md — workflow fixture demonstrating min-integrity without repos compiles cleanly
  • pkg/cli/compile_guard_policy_test.go — unit tests covering all guard policy variants: min-integrity-only (defaults repos to all), explicit repos=all, repos=public, repos array, and repos-only-without-min-integrity (which should still fail)

@pelikhan pelikhan marked this pull request as ready for review March 19, 2026 03:38
Copilot AI review requested due to automatic review settings March 19, 2026 03:38
Copy link
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

Fixes GitHub guard policy validation so workflows that specify only tools.github.min-integrity no longer fail validation; tools.github.repos is treated as "all" by default.

Changes:

  • Default tools.github.repos to "all" when omitted but min-integrity is present.
  • Update unit tests and add CLI compilation tests/fixtures covering min-integrity-only and other guard policy scenarios.
  • Update scratchpad documentation to reflect the new defaulting behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scratchpad/guard-policies-specification.md Updates spec text/examples to document repos defaulting behavior.
scratchpad/dev.md Updates developer docs to match the new guard policy requirements/defaults.
pkg/workflow/tools_validation.go Implements the new defaulting behavior in guard policy validation.
pkg/workflow/tools_validation_test.go Updates validation tests to expect success when repos is omitted.
pkg/cli/workflows/test-guard-policy-min-integrity-only.md Adds a workflow fixture demonstrating min-integrity without repos.
pkg/cli/compile_guard_policy_test.go Adds compilation-level tests for multiple guard policy configurations.

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

You can also share your feedback on Copilot code review. Take the survey.

toolsValidationLog.Printf("Missing repos in guard policy for workflow: %s", workflowName)
return errors.New("invalid guard policy: 'github.repos' is required. Use 'all', 'public', or an array of repository patterns (e.g., ['owner/repo', 'owner/*'])")
toolsValidationLog.Printf("Defaulting repos to 'all' in guard policy for workflow: %s", workflowName)
github.Repos = "all"
Comment on lines +304 to 311
name: "missing repos field defaults to all",
toolsMap: map[string]any{
"github": map[string]any{
"min-integrity": "unapproved",
},
},
shouldError: true,
errorMsg: "'github.repos' is required",
shouldError: false,
},
require.NoError(t, err, "Failed to write workflow file")

compiler := workflow.NewCompiler()
err = CompileWorkflowWithValidation(compiler, workflowPath, false, false, false, false, false, false)
@pelikhan pelikhan merged commit 3f72d35 into main Mar 19, 2026
86 checks passed
@pelikhan pelikhan deleted the copilot/fix-invalid-guard-policy branch March 19, 2026 03:45
github-actions bot added a commit that referenced this pull request Mar 19, 2026
- Add inline JavaScript script handlers (`safe-outputs.scripts`) section
  to custom-safe-outputs.md, documenting the new in-process handler
  feature added in #21582
- Fix github-tools.md guard policy description: repos defaults to "all"
  when omitted, only min-integrity is required (#21718)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
github-actions bot added a commit that referenced this pull request Mar 19, 2026
- Add Safe Output Scripts term (safe-outputs.scripts, #21582)
- Update Guard Policy: repos now defaults to 'all' when omitted (#21718)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

invalid guard policy: 'github.repos' is required...' should not be given when there's only one repo

3 participants