diff --git a/github/resource_github_repository_custom_property.go b/github/resource_github_repository_custom_property.go index 9da207a1be..8c6d3ce8c6 100644 --- a/github/resource_github_repository_custom_property.go +++ b/github/resource_github_repository_custom_property.go @@ -69,6 +69,9 @@ func resourceGithubRepositoryCustomPropertyCreate(d *schema.ResourceData, meta a // The propertyValue can either be a list of strings or a string switch propertyType { case github.PropertyValueTypeString, github.PropertyValueTypeSingleSelect, github.PropertyValueTypeURL, github.PropertyValueTypeTrueFalse: + if len(propertyValue) == 0 { + return fmt.Errorf("property_value must contain at least one element for property_type %q", propertyType) + } customProperty.Value = propertyValue[0] case github.PropertyValueTypeMultiSelect: customProperty.Value = propertyValue