Skip to content

fix: make bytebase_group.members optional and release 3.17.3#193

Merged
d-bytebase merged 2 commits intomainfrom
fix-group-members-required-optional
Apr 21, 2026
Merged

fix: make bytebase_group.members optional and release 3.17.3#193
d-bytebase merged 2 commits intomainfrom
fix-group-members-required-optional

Conversation

@d-bytebase
Copy link
Copy Markdown
Contributor

Summary

  • Flip bytebase_group.members from Required: true to Optional: true so the terraform-plugin-sdk/v2 core schema does not auto-inject MinItems=1 on registration
  • Bump VERSION to 3.17.3 and update the tutorial pin

Background

#191 (3.17.2) removed the literal MinItems: 1 and the runtime "at least 1 owner" guard, but a customer reported the plan still fails with:

Error: Insufficient members blocks

Root cause is in the SDK at helper/schema/core_schema.go:211-214:

if s.Required && s.MinItems == 0 {
    // configschema doesn't have a "required" representation for nested
    // blocks, but we can fake it by requiring at least one item.
    ret.MinItems = 1
}

When a nested block is Required: true with MinItems unset, the SDK synthesizes MinItems = 1 on the configschema that Terraform core uses for validation — this runs before any provider code executes, so the runtime guard removal in #191 never gets a chance. Conversely, the same function clears MinItems when Optional: true is set (lines 216-222), so Optional is the documented escape hatch.

The nested member / role attributes stay Required: true — those only apply when a members block is present, which is the desired behavior.

The runtime path already handles an empty set: convertToMemberList type-asserts d.Get("members").(*schema.Set), which returns a non-nil empty set when the block is omitted, so iteration just yields no members.

Test plan

  • terraform plan against a bytebase_group resource with no members block succeeds
  • terraform plan against a bytebase_group resource with populated members still works as before
  • Existing state with members continues to round-trip through terraform refresh

🤖 Generated with Claude Code

The terraform-plugin-sdk/v2 core schema auto-injects MinItems=1 whenever
a nested block is Required with MinItems=0 (core_schema.go:211-214), so
removing the literal MinItems:1 in #191 was not enough to allow an empty
members block — Terraform core still rejects the config with
"Insufficient members blocks" before any RPC reaches the server.

Flip members to Optional so the SDK does not reinject the constraint.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@d-bytebase d-bytebase requested review from ecmadao and vsai12 April 21, 2026 17:22
Step 3 of TestAccGroup_InvalidInput asserted that a bytebase_group with
no members block produces a validation error. That is exactly the
behavior this change (and #191) removes, so the step now fails with
"expected an error but got none".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@d-bytebase d-bytebase merged commit fb0f14a into main Apr 21, 2026
3 checks passed
@d-bytebase d-bytebase deleted the fix-group-members-required-optional branch April 21, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants