Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 27 additions & 0 deletions actions/setup/js/safe_outputs_tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 24 additions & 5 deletions pkg/workflow/js/safe_outputs_tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -317,18 +321,27 @@
"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": {
"type": "string",
"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."
}
},
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1168,4 +1187,4 @@
"additionalProperties": false
}
}
]
]
89 changes: 86 additions & 3 deletions pkg/workflow/safe_output_validation_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ 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": {
DefaultMax: 1,
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": {
Expand All @@ -74,36 +76,43 @@ 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": {
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"
},
},
"add_reviewer": {
DefaultMax: 3,
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": {
DefaultMax: 1,
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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -189,20 +208,23 @@ 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": {
DefaultMax: 1,
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": {
DefaultMax: 1,
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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion pkg/workflow/safe_output_validation_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
}

Expand Down
Loading