Skip to content

[BUG]: organization_ruleset - interface conversion error when required_status_checks omits optional fields #2776

Closed as not planned

Description

@maxafinder

Expected Behavior

When creating a github_organization_ruleset or github_repository_ruleset with a required_status_checks block that only specifies required_check, the provider should apply default values for the optional fields do_not_enforce_on_create and strict_required_status_checks_policy.

Example configuration:

rules {
  required_status_checks {
    required_check {
      context = "example-check"
    }
  }
}

Expected outcome:

  • The ruleset should be created successfully.
  • do_not_enforce_on_create should default to false.
  • strict_required_status_checks_policy should default to false.

The provider should handle optional fields, either by:

  1. Providing defaults so the fields are always present in the configuration map, or
  2. Checking if the fields exist before performing type assertions and using appropriate defaults when they're absent.

Actual Behavior

The provider panics with the error:

panic: interface conversion: interface {} is nil, not bool

goroutine 47 [running]:
github.com/integrations/terraform-provider-github/v6/github.expandRules(...)
github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:343

When do_not_enforce_on_create or strict_required_status_checks_policy are not specified in the required_status_checks block, the code at line 343 attempts to perform a type assertion on a nil value (non-existent map key), causing the provider to crash and the resource creation to fail completely.

Terraform Version

Terraform v1.13.3
on darwin_arm64

Provider plugin: v6.6.0

Affected Resource(s)

  • github_repository_ruleset
  • github_organization_ruleset

Terraform Configuration Files

resource "github_organization_ruleset" "require_pr_title_validation" {
  name        = "require-signed-commits"
  target      = "branch"
  enforcement = "active"

  conditions {
    ref_name {
      include = ["~ALL"]
      exclude = []
    }
    repository_name {
      include = ["*"]
      exclude = []
    }
  }

  rules {
    required_status_checks {
      required_check {
        context = "validate-pr-title"
      }
    }
  }
}

Steps to Reproduce

terraform apply

Debug Output

Panic Output

Stack trace from the terraform-provider-github_v6.6.0 plugin:

panic: interface conversion: interface {} is nil, not bool

goroutine 47 [running]:
github.com/integrations/terraform-provider-github/v6/github.expandRules({0xc00056c3c0?, 0xf1b546?, 0x0?}, 0x1)
	github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:343 +0x2a54
github.com/integrations/terraform-provider-github/v6/github.resourceGithubRulesetObject(0xc00041b580, {0xc000012c20, 0xb})
	github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:33 +0x2c5
github.com/integrations/terraform-provider-github/v6/github.resourceGithubOrganizationRulesetCreate(0xc00041b580, {0xd352c0, 0xc000252b80})
	github.com/integrations/terraform-provider-github/v6/github/resource_github_organization_ruleset.go:511 +0x5d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x107d470?, {0x107d470?, 0xc00048ec60?}, 0xd?, {0xd352c0?, 0xc000252b80?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:794 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003a0c40, {0x107d470, 0xc00048ec60}, 0xc0004f0680, 0xc00041b400, {0xd352c0, 0xc000252b80})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:937 +0xa89
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00036e5b8, {0x107d470?, 0xc00048eba0?}, 0xc000021810)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000267860, {0x107d470?, 0xc00048e1e0?}, 0xc0000f4850)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xee16c0, 0xc000267860}, {0x107d470, 0xc00048e1e0}, 0xc00041a900, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00017f000, {0x107d470, 0xc00048e150}, {0x1081d68, 0xc000002180}, 0xc00042fb00, 0xc00046c7b0, 0x1719558, 0x0)
	google.golang.org/[email protected]/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc00017f000, {0x1081d68, 0xc000002180}, 0xc00042fb00)
	google.golang.org/[email protected]/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/[email protected]/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 24
	google.golang.org/[email protected]/server.go:1030 +0x125

Error: The terraform-provider-github_v6.6.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    Type: Bug
    Status: Triage
    on Oct 10, 2025
  2. changed the title [-][BUG]: Organization ruleset - interface conversion error when required_status_checks omits optional fields[/-] [+][BUG]: organization_ruleset - interface conversion error when required_status_checks omits optional fields[/+] on Oct 10, 2025
  3. sosoriov commented on Oct 14, 2025

    @sosoriov

    I got the same error running the apply command. The plan works.

    This is my ruleset config:

      - name: "Standard Branch Protection"
        target: "branch"
        enforcement: "active"
        description: "Standard protection for main branches across all repositories (except lab repos)"
    
        targeting:
          ref_names:
            include: ["seboso-test-branch"]
          repositories:
            include: ["~ALL"]
            exclude: ["lab-*"] # Lab repos have looser rules
    
        rules:
          pull_request:
            required_approving_review_count: 1
            require_code_owner_review: true
            dismiss_stale_reviews_on_push: false
            require_last_push_approval: false
            required_review_thread_resolution: false
    
          status_checks:
            - context: "ci"
          strict_checks: false
    
          block_force_pushes: true
          require_signed_commits: false
          require_linear_history: false
      │ Error: Plugin did not respond
      │ 
      │   with module.ruleset["Standard Branch Protection"].github_organization_ruleset.this,
      │   on ../../modules/ruleset/main.tf line 1, in resource "github_organization_ruleset" "this":
      │    1: resource "github_organization_ruleset" "this" {
      │ 
      │ The plugin encountered an error, and failed to respond to the
      │ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
      │ contain more details.
      ╵
      
      Stack trace from the terraform-provider-github_v6.6.0 plugin:
      
      panic: interface conversion: interface {} is nil, not bool
      
      goroutine 64 [running]:
      github.com/integrations/terraform-provider-github/v6/github.expandRules({0xc0006bc660?, 0xf1b546?, 0x0?}, 0x1)
            github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:343 +0x2a54
      github.com/integrations/terraform-provider-github/v6/github.resourceGithubRulesetObject(0xc0000a3180, {0xc00003a025, 0x8})
            github.com/integrations/terraform-provider-github/v6/github/respository_rules_utils.go:33 +0x2c5
      github.com/integrations/terraform-provider-github/v6/github.resourceGithubOrganizationRulesetCreate(0xc0000a3180, {0xd352c0, 0xc000060780})
            github.com/integrations/terraform-provider-github/v6/github/resource_github_organization_ruleset.go:511 +0x5d
      github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x107d470?, {0x107d470?, 0xc0005d6cf0?}, 0xd?, {0xd352c0?, 0xc000060780?})
            github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:794 +0x15f
      github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00046ddc0, {0x107d470, 0xc0005d6cf0}, 0xc0006341a0, 0xc0000a3000, {0xd352c0, 0xc000060780})
            github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:937 +0xa89
      github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0004de018, {0x107d470?, 0xc0005d6c30?}, 0xc0005da370)
            github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1153 +0xd5c
      github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000278b40, {0x107d470?, 0xc0005d6240?}, 0xc000260000)
            github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:865 +0x3d0
      github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xee16c0, 0xc000278b40}, {0x107d470, 0xc0005d6240}, 0xc0000a2080, 0x0)
            github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:518 +0x1a6
      google.golang.org/grpc.(*Server).processUnaryRPC(0xc000450000, {0x107d470, 0xc0005d61b0}, {0x1081d68, 0xc0002ce300}, 0xc000608000, 0xc0002c77d0, 0x1719558, 0x0)
            google.golang.org/[email protected]/server.go:1369 +0xdf8
      google.golang.org/grpc.(*Server).handleStream(0xc000450000, {0x1081d68, 0xc0002ce300}, 0xc000608000)
            google.golang.org/[email protected]/server.go:1780 +0xe8b
      google.golang.org/grpc.(*Server).serveStreams.func2.1()
            google.golang.org/[email protected]/server.go:1019 +0x8b
      created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 58
            google.golang.org/[email protected]/server.go:1030 +0x125
      
      Error: The terraform-provider-github_v6.6.0 plugin crashed!
    
  4. stevehipwell commented on Jan 15, 2026

    @stevehipwell
    Collaborator

    @maxafinder @sosoriov could you check if this has been fixed in the latest provider version?

  5. deiga commented on Mar 22, 2026

    @deiga
    Collaborator

    Closing due to inactivity and lack of reproduction information

  6. moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Activeon Mar 22, 2026
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

    Status: TriageType: Bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions