Skip to content

fix: improve github_organization_custom_properties resource#3234

Open
mkushakov wants to merge 2 commits intointegrations:mainfrom
mkushakov:fix/org-custom-properties-improvements
Open

fix: improve github_organization_custom_properties resource#3234
mkushakov wants to merge 2 commits intointegrations:mainfrom
mkushakov:fix/org-custom-properties-improvements

Conversation

@mkushakov
Copy link

Summary

Fix several bugs and improve the github_organization_custom_properties resource to handle edge cases correctly and align with GitHub API behavior.

Resolves #2806

Changes

Bug Fixes

  • Remove broken CustomizeDiff: The existing CustomizeDiff referenced a slug field that does not exist in the schema, causing unnecessary plan diffs. Removed entirely.
  • Fix Update double-read: The Update function was reading the resource state twice unnecessarily. Removed the redundant read.
  • Fix missing 404 handling in Read: If a custom property is deleted outside of Terraform, the Read function now gracefully removes it from state instead of returning an error.
  • Use GetOk for optional fields: Changed allowed_values and default_value reads to use GetOk instead of Get to correctly distinguish between unset and empty values.

Improvements

  • Add ForceNew to immutable fields: property_name and value_type cannot be changed on an existing custom property — they now force recreation.
  • Make value_type Required: This field is required by the GitHub API and should not be optional.
  • Add allowed_values validation: allowed_values is now required when value_type is single_select or multi_select, and rejected for string and true_false types via CustomizeDiff.
  • Add checkOrganization guard: Create/Read/Update/Delete now validate that an organization is configured.
  • Improve error messages: All API errors are now wrapped with fmt.Errorf for better context.
  • Add resource Description.

Tests

  • Added validation test: rejects allowed_values for string type.
  • Added validation test: requires allowed_values for single_select type.

Testing

  • go build ./... — passes
  • go vet ./... — passes
  • New acceptance tests added for validation logic

- Remove broken CustomizeDiff referencing non-existent 'slug' field
- Make 'property_name' ForceNew (renaming creates a new property, orphans old)
- Make 'value_type' Required and ForceNew (can't create without type, changing type requires recreation)
- Add allowed_values validation: required for select types, rejected for others
- Add checkOrganization guard to all CRUD functions
- Add graceful 404 handling in Read (removes from state instead of erroring)
- Improve error messages with context
- Fix Update double-read (Create already calls Read at the end)
- Add resource Description
- Use GetOk for optional fields to avoid sending zero values

Resolves integrations#2806
@github-actions
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions bot added the Type: Bug Something isn't working as documented label Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: GitHub_organization_custom_properties

1 participant