From 45357ac824f76c9aa096efd3154c476677269411 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 22:16:10 +0000 Subject: [PATCH 1/2] Initial plan From 960f578d870543d718659d7f395d8d3524922756 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 22:43:24 +0000 Subject: [PATCH 2/2] Fix: Ensure validation consistency across all safe output types and tools.json files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/safe_outputs_tools.json | 27 ++++++ pkg/workflow/js/safe_outputs_tools.json | 29 ++++-- pkg/workflow/safe_output_validation_config.go | 89 ++++++++++++++++++- .../safe_output_validation_config_test.go | 16 +++- 4 files changed, 152 insertions(+), 9 deletions(-) diff --git a/actions/setup/js/safe_outputs_tools.json b/actions/setup/js/safe_outputs_tools.json index 2b8c56bb9bf..576bbd55299 100644 --- a/actions/setup/js/safe_outputs_tools.json +++ b/actions/setup/js/safe_outputs_tools.json @@ -436,6 +436,10 @@ "agent": { "type": "string", "description": "Agent identifier to assign. Defaults to 'copilot' (the Copilot coding agent) if not specified." + }, + "pull_request_repo": { + "type": "string", + "description": "Target repository where the pull request should be created, in 'owner/repo' format. If omitted, the PR will be created in the same repository as the issue. This allows issues and code to live in different repositories. The global pull-request-repo configuration (if set) is automatically allowed; additional repositories must be listed in allowed-pull-request-repos." } }, "additionalProperties": false @@ -518,6 +522,29 @@ "issue_number": { "type": ["number", "string"], "description": "Issue number to update. This is the numeric ID from the GitHub URL (e.g., 789 in github.com/owner/repo/issues/789). Required when the workflow target is '*' (any issue)." + }, + "operation": { + "type": "string", + "enum": ["replace", "append", "prepend", "replace-island"], + "description": "How to update the issue body: 'append' (default - add to end with separator), 'prepend' (add to start with separator), 'replace' (overwrite entire body), or 'replace-island' (update a run-specific section)." + }, + "labels": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Replace the issue labels with this list (e.g., ['bug', 'tracking:foo']). Labels must exist in the repository." + }, + "assignees": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Replace the issue assignees with this list of GitHub usernames (e.g., ['octocat', 'mona'])." + }, + "milestone": { + "type": ["number", "string"], + "description": "Milestone number to assign (e.g., 1). Use null to clear." } }, "additionalProperties": false diff --git a/pkg/workflow/js/safe_outputs_tools.json b/pkg/workflow/js/safe_outputs_tools.json index 2d4e304afa4..49d6c2036bd 100644 --- a/pkg/workflow/js/safe_outputs_tools.json +++ b/pkg/workflow/js/safe_outputs_tools.json @@ -239,6 +239,10 @@ "type": "string" }, "description": "Labels to categorize the PR (e.g., 'enhancement', 'bugfix'). Labels must exist in the repository." + }, + "draft": { + "type": "boolean", + "description": "Whether to create the PR as a draft. Draft PRs cannot be merged until marked as ready for review. Use mark_pull_request_as_ready_for_review to convert a draft PR. Default: true." } }, "additionalProperties": false @@ -317,10 +321,16 @@ "description": "Reply to an existing review comment on a pull request. Use this to respond to feedback, answer questions, or acknowledge review comments. The comment_id must be the numeric ID of an existing review comment.", "inputSchema": { "type": "object", - "required": ["comment_id", "body"], + "required": [ + "comment_id", + "body" + ], "properties": { "comment_id": { - "type": ["number", "string"], + "type": [ + "number", + "string" + ], "description": "The numeric ID of the review comment to reply to (e.g., 42853901 from the comment URL or API response)." }, "body": { @@ -328,7 +338,10 @@ "description": "The reply text in Markdown format. Provide a clear response to the review comment." }, "pull_request_number": { - "type": ["number", "string"], + "type": [ + "number", + "string" + ], "description": "Pull request number to reply on. This is the numeric ID from the GitHub URL (e.g., 876 in github.com/owner/repo/pull/876). If omitted, replies on the PR that triggered this workflow." } }, @@ -340,7 +353,9 @@ "description": "Resolve a review thread on a pull request. Use this to mark a review conversation as resolved after addressing the feedback. The thread_id must be the node ID of the review thread (e.g., PRRT_kwDO...).", "inputSchema": { "type": "object", - "required": ["thread_id"], + "required": [ + "thread_id" + ], "properties": { "thread_id": { "type": "string", @@ -690,6 +705,10 @@ "string" ], "description": "Pull request number to update. This is the numeric ID from the GitHub URL (e.g., 234 in github.com/owner/repo/pull/234). Required when the workflow target is '*' (any PR)." + }, + "draft": { + "type": "boolean", + "description": "Whether the PR should be a draft (true) or ready for review (false). Use to convert between draft and ready states." } }, "additionalProperties": false @@ -1168,4 +1187,4 @@ "additionalProperties": false } } -] \ No newline at end of file +] diff --git a/pkg/workflow/safe_output_validation_config.go b/pkg/workflow/safe_output_validation_config.go index 2a587dd4847..998778f4f6e 100644 --- a/pkg/workflow/safe_output_validation_config.go +++ b/pkg/workflow/safe_output_validation_config.go @@ -58,6 +58,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ DefaultMax: 1, Fields: map[string]FieldValidation{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "add_comment": { @@ -65,6 +66,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "item_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "create_pull_request": { @@ -74,6 +76,8 @@ var ValidationConfig = map[string]TypeValidationConfig{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "branch": {Required: true, Type: "string", Sanitize: true, MaxLength: 256}, "labels": {Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: 128}, + "draft": {Type: "boolean"}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "add_labels": { @@ -81,6 +85,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "labels": {Required: true, Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: 128}, "item_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "add_reviewer": { @@ -88,6 +93,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "reviewers": {Required: true, Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: MaxGitHubUsernameLength}, "pull_request_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "assign_milestone": { @@ -95,15 +101,18 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "issue_number": {IssueOrPRNumber: true}, "milestone_number": {Required: true, PositiveInteger: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "assign_to_agent": { DefaultMax: 1, CustomValidation: "requiresOneOf:issue_number,pull_number", Fields: map[string]FieldValidation{ - "issue_number": {IssueNumberOrTemporaryID: true}, - "pull_number": {OptionalPositiveInteger: true}, - "agent": {Type: "string", Sanitize: true, MaxLength: 128}, + "issue_number": {IssueNumberOrTemporaryID: true}, + "pull_number": {OptionalPositiveInteger: true}, + "agent": {Type: "string", Sanitize: true, MaxLength: 128}, + "pull_request_repo": {Type: "string", MaxLength: 256}, // Optional: repository where the PR should be created + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "assign_to_user": { @@ -112,6 +121,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ "issue_number": {IssueOrPRNumber: true}, "assignees": {Type: "[]string", Sanitize: true, MaxLength: 39}, // GitHub username max length is 39 "assignee": {Type: "string", Sanitize: true, MaxLength: 39}, // Single assignee alternative + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "update_issue": { @@ -121,7 +131,12 @@ var ValidationConfig = map[string]TypeValidationConfig{ "status": {Type: "string", Enum: []string{"open", "closed"}}, "title": {Type: "string", Sanitize: true, MaxLength: 128}, "body": {Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, + "operation": {Type: "string", Enum: []string{"replace", "append", "prepend", "replace-island"}}, + "labels": {Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: 128}, + "assignees": {Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: MaxGitHubUsernameLength}, + "milestone": {OptionalPositiveInteger: true}, "issue_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "update_pull_request": { @@ -131,7 +146,9 @@ var ValidationConfig = map[string]TypeValidationConfig{ "title": {Type: "string", Sanitize: true, MaxLength: 256}, "body": {Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "operation": {Type: "string", Enum: []string{"replace", "append", "prepend"}}, + "draft": {Type: "boolean"}, "pull_request_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "push_to_pull_request_branch": { @@ -151,6 +168,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "start_line": {OptionalPositiveInteger: true}, "side": {Type: "string", Enum: []string{"LEFT", "RIGHT"}}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "submit_pull_request_review": { @@ -166,6 +184,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ "comment_id": {Required: true, PositiveInteger: true}, "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "pull_request_number": {OptionalPositiveInteger: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "resolve_pull_request_review_thread": { @@ -189,6 +208,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "reason": {Type: "string", Enum: []string{"RESOLVED", "DUPLICATE", "OUTDATED", "ANSWERED"}}, "discussion_number": {OptionalPositiveInteger: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "close_issue": { @@ -196,6 +216,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "issue_number": {OptionalPositiveInteger: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "close_pull_request": { @@ -203,6 +224,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "body": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, "pull_request_number": {OptionalPositiveInteger: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "missing_tool": { @@ -250,6 +272,7 @@ var ValidationConfig = map[string]TypeValidationConfig{ Fields: map[string]FieldValidation{ "parent_issue_number": {Required: true, IssueNumberOrTemporaryID: true}, "sub_issue_number": {Required: true, IssueNumberOrTemporaryID: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" }, }, "update_project": { @@ -284,6 +307,66 @@ var ValidationConfig = map[string]TypeValidationConfig{ "target_date": {Type: "string", Pattern: "^\\d{4}-\\d{2}-\\d{2}$", PatternError: "must be in YYYY-MM-DD format"}, }, }, + "update_discussion": { + DefaultMax: 1, + CustomValidation: "requiresOneOf:title,body", + Fields: map[string]FieldValidation{ + "title": {Type: "string", Sanitize: true, MaxLength: 128}, + "body": {Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, + "discussion_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" + }, + }, + "remove_labels": { + DefaultMax: 5, + Fields: map[string]FieldValidation{ + "labels": {Required: true, Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: 128}, + "item_number": {IssueOrPRNumber: true}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" + }, + }, + "unassign_from_user": { + DefaultMax: 1, + Fields: map[string]FieldValidation{ + "issue_number": {IssueOrPRNumber: true}, + "assignees": {Type: "array", ItemType: "string", ItemSanitize: true, ItemMaxLength: MaxGitHubUsernameLength}, + "assignee": {Type: "string", Sanitize: true, MaxLength: MaxGitHubUsernameLength}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" + }, + }, + "hide_comment": { + DefaultMax: 5, + Fields: map[string]FieldValidation{ + "comment_id": {Required: true, Type: "string", MaxLength: 256}, + "reason": {Type: "string", Enum: []string{"SPAM", "ABUSE", "OFF_TOPIC", "OUTDATED", "RESOLVED"}}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" + }, + }, + "missing_data": { + DefaultMax: 20, + Fields: map[string]FieldValidation{ + "data_type": {Type: "string", Sanitize: true, MaxLength: 128}, + "reason": {Type: "string", Sanitize: true, MaxLength: 256}, + "context": {Type: "string", Sanitize: true, MaxLength: 256}, + "alternatives": {Type: "string", Sanitize: true, MaxLength: 256}, + }, + }, + "autofix_code_scanning_alert": { + DefaultMax: 10, + Fields: map[string]FieldValidation{ + "alert_number": {PositiveInteger: true}, + "fix_description": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, + "fix_code": {Required: true, Type: "string", MaxLength: MaxBodyLength}, + }, + }, + "mark_pull_request_as_ready_for_review": { + DefaultMax: 1, + Fields: map[string]FieldValidation{ + "pull_request_number": {IssueOrPRNumber: true}, + "reason": {Required: true, Type: "string", Sanitize: true, MaxLength: MaxBodyLength}, + "repo": {Type: "string", MaxLength: 256}, // Optional: target repository in format "owner/repo" + }, + }, } // GetValidationConfigJSON returns the validation configuration as indented JSON diff --git a/pkg/workflow/safe_output_validation_config_test.go b/pkg/workflow/safe_output_validation_config_test.go index c89252d4ebd..fcce47b74b5 100644 --- a/pkg/workflow/safe_output_validation_config_test.go +++ b/pkg/workflow/safe_output_validation_config_test.go @@ -47,6 +47,13 @@ func TestGetValidationConfigJSON(t *testing.T) { "noop", "create_code_scanning_alert", "link_sub_issue", + "update_discussion", + "remove_labels", + "unassign_from_user", + "hide_comment", + "missing_data", + "autofix_code_scanning_alert", + "mark_pull_request_as_ready_for_review", } for _, typeName := range expectedTypes { @@ -135,7 +142,7 @@ func TestGetValidationConfigForType(t *testing.T) { typeName: "create_issue", wantFound: true, wantMax: 1, - wantFields: []string{"title", "body", "labels", "parent", "temporary_id"}, + wantFields: []string{"title", "body", "labels", "parent", "temporary_id", "repo"}, }, { name: "link_sub_issue type", @@ -179,8 +186,15 @@ func TestGetDefaultMaxForType(t *testing.T) { {"create_issue", 1}, {"add_labels", 5}, {"missing_tool", 20}, + {"missing_data", 20}, {"create_code_scanning_alert", 40}, + {"autofix_code_scanning_alert", 10}, {"link_sub_issue", 5}, + {"hide_comment", 5}, + {"remove_labels", 5}, + {"update_discussion", 1}, + {"unassign_from_user", 1}, + {"mark_pull_request_as_ready_for_review", 1}, {"unknown_type", 1}, // Default fallback }