@@ -166,7 +166,8 @@ func validateRulesetRules(ctx context.Context, d *schema.ResourceDiff) error {
166166func validateConditionsFieldForBranchAndTagTargets (ctx context.Context , target github.RulesetTarget , conditions map [string ]any , isOrg bool ) error {
167167 tflog .Debug (ctx , fmt .Sprintf ("Validating conditions field for %s target" , target ), map [string ]any {"target" : target , "conditions" : conditions , "isOrg" : isOrg })
168168
169- if conditions ["ref_name" ] == nil || len (conditions ["ref_name" ].([]any )) == 0 {
169+ refName , ok := conditions ["ref_name" ].([]any )
170+ if ! ok || len (refName ) == 0 || refName [0 ] == nil {
170171 tflog .Debug (ctx , fmt .Sprintf ("Missing ref_name for %s target" , target ), map [string ]any {"target" : target })
171172 return fmt .Errorf ("ref_name must be set for %s target" , target )
172173 }
@@ -178,7 +179,7 @@ func validateConditionsFieldForBranchAndTagTargets(ctx context.Context, target g
178179func validateConditionsFieldForPushTarget (ctx context.Context , conditions map [string ]any ) error {
179180 tflog .Debug (ctx , "Validating conditions field for push target" , map [string ]any {"target" : "push" , "conditions" : conditions })
180181
181- if conditions [ "ref_name" ] != nil && len ( conditions ["ref_name" ].([]any )) > 0 {
182+ if refName , ok := conditions ["ref_name" ].([]any ); ok && len ( refName ) > 0 && refName [ 0 ] != nil {
182183 tflog .Debug (ctx , "Invalid ref_name for push target" , map [string ]any {"ref_name" : conditions ["ref_name" ]})
183184 return fmt .Errorf ("ref_name must not be set for push target" )
184185 }
0 commit comments