fix: enforce draft as policy in create-pull-request, not agent-overridable fallback#20608
fix: enforce draft as policy in create-pull-request, not agent-overridable fallback#20608
draft as policy in create-pull-request, not agent-overridable fallback#20608Conversation
…llback Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
draft as policy in create-pull-request, not agent-overridable fallback
There was a problem hiding this comment.
Pull request overview
This PR ensures create-pull-request treats draft as a config-enforced policy (not an agent-overridable fallback) and adds end-to-end tests to prevent regressions.
Changes:
- Enforce
draftstrictly from config (draftDefault) and emit a warning when the agent attempts to override it. - Add integration-style tests verifying
github.rest.pulls.createreceives the config-enforceddraftvalue and that warnings only occur on override attempts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| actions/setup/js/create_pull_request.cjs | Enforces config-controlled draft policy and warns on agent override attempts. |
| actions/setup/js/create_pull_request.test.cjs | Adds tests covering draft policy enforcement and warning behavior. |
💡 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.
| let tempDir; | ||
| let originalEnv; | ||
|
|
||
| beforeEach(() => { | ||
| originalEnv = { ...process.env }; | ||
| process.env.GH_AW_WORKFLOW_ID = "test-workflow"; | ||
| process.env.GITHUB_REPOSITORY = "test-owner/test-repo"; | ||
| process.env.GITHUB_BASE_REF = "main"; | ||
| tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "create-pr-draft-test-")); | ||
|
|
There was a problem hiding this comment.
tempDir is created and cleaned up in this test suite, but it is never used (no files are written there and the process CWD isn’t changed). This adds unnecessary setup/teardown work and can be removed, or alternatively use it to write a real patch if the intent was to exercise the filesystem path.
- Add add-wizard command to CLI reference with --skip-secret flag (#20598) - Document that Codex web-search is disabled by default (#20607) - Clarify that draft is a configuration policy in create-pull-request (#20608) - Document compile-time warnings for push-to-pull-request-branch with target: "*" (#20580) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
safe-outputs.create-pull-request.draftwas treated as a default rather than a policy — the agent could include"draft": truein its message to bypass adraft: falseconfig, violating the Layer 1 security architecture.Changes
create_pull_request.cjs: Always usedraftDefault(from config); emitcore.warningwhen the agent message contains adraftvalue that conflicts with config — consistent with howautoMergeandallowEmptyalready work:create_pull_request.test.cjs: 5 integration tests callingmain()end-to-end verifyinggithub.rest.pulls.createreceives the config-enforceddraftvalue and that the warning fires only on genuine override attempts.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.