Skip to content

GitHub.BranchProtection: requiredStatusChecks.checks fails with "Invalid request" #1952

Description

@peterje

Declaring required status checks with checks makes GitHub reject the branch protection update with HttpError: Invalid request.

BranchProtection.ts always sends contexts: checks.contexts ?? [], and adds checks alongside it when provided. GitHub's update-branch-protection endpoint does not accept both contexts and checks in the same request, so any use of checks fails. Using contexts instead works.

yield* GitHub.BranchProtection("main", {
  owner, repository, branch: "main",
  requiredStatusChecks: {
    strict: false,
    checks: [{ context: "Verify" }, { context: "API tests" }], // → HttpError: Invalid request.
  },
});

Observed with alchemy 2.0.0-beta.80; the same code is on main (ea384f0), packages/alchemy/src/GitHub/BranchProtection.ts:433.

Suggested fix: send checks without contexts when checks is given, and contexts only otherwise.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions