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
2 changes: 0 additions & 2 deletions actions/setup/js/validate_context_variables.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* - github.event.comment.id
* - github.event.deployment.id
* - github.event.deployment_status.id
* - github.event.head_commit.id
* - github.event.installation.id
* - github.event.workflow_job.run_id
* - github.event.label.id
Expand Down Expand Up @@ -61,7 +60,6 @@ const NUMERIC_CONTEXT_PATHS = [
{ path: ["payload", "comment", "id"], name: "github.event.comment.id" },
{ path: ["payload", "deployment", "id"], name: "github.event.deployment.id" },
{ path: ["payload", "deployment_status", "id"], name: "github.event.deployment_status.id" },
{ path: ["payload", "head_commit", "id"], name: "github.event.head_commit.id" },
{ path: ["payload", "installation", "id"], name: "github.event.installation.id" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot review all other entires to ensure they are numbers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all entries in NUMERIC_CONTEXT_PATHS. All remaining fields are confirmed to be numeric (integers) per GitHub webhook documentation:

  • All .number fields (issue, PR, discussion, milestone, check_run, check_suite, workflow_run) = integers
  • All resource .id fields (check_run, check_suite, comment, deployment, installation, workflow_job, label, milestone, organization, page, project, repository, review, sender, workflow_run) = integers
  • github.run_id and github.run_number = integers
  • workflow_job.run_id = integer

The only non-numeric field (head_commit.id - a Git SHA string) was correctly removed in commit 991bf3d.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified. All remaining entries in the NUMERIC_CONTEXT_PATHS array are integers per GitHub webhook documentation. The non-numeric field (head_commit.id - a commit SHA) was removed.

{ path: ["payload", "workflow_job", "run_id"], name: "github.event.workflow_job.run_id" },
{ path: ["payload", "label", "id"], name: "github.event.label.id" },
Expand Down
22 changes: 20 additions & 2 deletions actions/setup/js/validate_context_variables.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,20 @@ describe("NUMERIC_CONTEXT_PATHS", () => {
});
});

it("should have 31 context paths", () => {
expect(NUMERIC_CONTEXT_PATHS.length).toBe(31);
it("should have 30 context paths", () => {
expect(NUMERIC_CONTEXT_PATHS.length).toBe(30);
});

it("should not include duplicate names", () => {
const names = NUMERIC_CONTEXT_PATHS.map(p => p.name);
const uniqueNames = [...new Set(names)];
expect(uniqueNames.length).toBe(NUMERIC_CONTEXT_PATHS.length);
});

it("should not include github.event.head_commit.id (Git SHA, not numeric)", () => {
const found = NUMERIC_CONTEXT_PATHS.find(p => p.name === "github.event.head_commit.id");
expect(found).toBeUndefined();
});
});

describe("main", () => {
Expand Down Expand Up @@ -298,4 +303,17 @@ describe("main", () => {

expect(mockCore.setFailed).not.toHaveBeenCalled();
});

it("should not validate github.event.head_commit.id (Git SHA)", async () => {
// Add a Git commit SHA to the context
mockContext.payload.head_commit = {
id: "046ee07d682351acd49209ca43ba340931001c1a",
};

await main();

// Should pass because head_commit.id is not validated as numeric
expect(mockCore.setFailed).not.toHaveBeenCalled();
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("✅ All context variables validated successfully"));
});
});
Loading