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
9 changes: 6 additions & 3 deletions .github/workflows/campaign-generator.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions .github/workflows/issue-monster.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions .github/workflows/workflow-generator.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions actions/setup/js/safe_output_type_validator.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ const SAMPLE_VALIDATION_CONFIG = {
issue_number: { issueOrPRNumber: true },
},
},
assign_to_agent: {
defaultMax: 1,
customValidation: "requiresOneOf:issue_number,pull_number",
fields: {
issue_number: { optionalPositiveInteger: true },
pull_number: { optionalPositiveInteger: true },
agent: { type: "string", sanitize: true, maxLength: 128 },
},
},
create_pull_request_review_comment: {
defaultMax: 1,
customValidation: "startLineLessOrEqualLine",
Expand Down Expand Up @@ -356,6 +365,33 @@ describe("safe_output_type_validator", () => {
expect(result.isValid).toBe(false);
expect(result.error).toContain("requires at least one of");
});

it("should pass for assign_to_agent with issue_number", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");

const result = validateItem({ type: "assign_to_agent", issue_number: 123 }, "assign_to_agent", 1);

expect(result.isValid).toBe(true);
});

it("should pass for assign_to_agent with pull_number", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");

const result = validateItem({ type: "assign_to_agent", pull_number: 456 }, "assign_to_agent", 1);

expect(result.isValid).toBe(true);
});

it("should fail for assign_to_agent without issue_number or pull_number", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");

const result = validateItem({ type: "assign_to_agent", agent: "copilot" }, "assign_to_agent", 1);

expect(result.isValid).toBe(false);
expect(result.error).toContain("requires at least one of");
expect(result.error).toContain("issue_number");
expect(result.error).toContain("pull_number");
});
});

describe("custom validation: startLineLessOrEqualLine", () => {
Expand Down
6 changes: 4 additions & 2 deletions pkg/workflow/safe_output_validation_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ var ValidationConfig = map[string]TypeValidationConfig{
},
},
"assign_to_agent": {
DefaultMax: 1,
DefaultMax: 1,
CustomValidation: "requiresOneOf:issue_number,pull_number",
Fields: map[string]FieldValidation{
"issue_number": {Required: true, PositiveInteger: true},
"issue_number": {OptionalPositiveInteger: true},
"pull_number": {OptionalPositiveInteger: true},
"agent": {Type: "string", Sanitize: true, MaxLength: 128},
},
},
Expand Down
9 changes: 5 additions & 4 deletions pkg/workflow/safe_output_validation_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ func TestFieldValidationMarshaling(t *testing.T) {
func TestValidationConfigConsistency(t *testing.T) {
// Verify that all types with customValidation have valid validation rules
validCustomValidations := map[string]bool{
"requiresOneOf:status,title,body": true,
"requiresOneOf:title,body": true,
"startLineLessOrEqualLine": true,
"parentAndSubDifferent": true,
"requiresOneOf:status,title,body": true,
"requiresOneOf:title,body": true,
"requiresOneOf:issue_number,pull_number": true,
"startLineLessOrEqualLine": true,
"parentAndSubDifferent": true,
}

for typeName, config := range ValidationConfig {
Expand Down
Loading