Skip to content

[Bug] Setting a default branch name other than 'main' causes 422 Errors #125

@bzarboni1

Description

@bzarboni1

ISSUE

When creating new repositories, with branch names [production, non-production, development], and setting the default_branch = "production", there are 422 errors.

Terraform:

private_repositories = {
    myorg-gcp-00-bootstrap = {
      advance_security            = false
      allow_auto_merge            = true
      default_branch              = "production"
      delete_head_on_merge        = true
      dependabot_security_updates = false
      description                 = "Used to hold the bootstrap terraform for the GCP Organization"
      has_vulnerability_alerts    = true
      homepage                    = ""
      protected_branches          = ["production", "development", "non-production"]
      requires_web_commit_signing = true
      topics                      = ["gcp", "infrastructure-as-code"]
    }

Error:

│ Error: PATCH https://api.github.com/repos/FociSolutions/bupa-gcp-02-environments: 422 Validation Failed [{Resource:Repository Field:default_branch Code:invalid Message:The branch production was not found. Please push that ref first or create it via the Git Data API.}]
│ 
│   with module.private_repositories["bupa-gcp-02-environments"].module.repository_base.github_branch_default.default_branch,
│   on ../repository_base/repository.tf line 98, in resource "github_branch_default" "default_branch":
│   98: resource "github_branch_default" "default_branch" {
│ 

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