@@ -107,11 +107,15 @@ func (c *ConditionSetClient) Create(ctx context.Context, conditionSetType models
107107 }
108108
109109 conditionSetCreate := models.ConditionSetCreate {
110- Key : conditionSetPlan .Key .ValueString (),
111- Name : conditionSetPlan .Name .ValueString (),
112- Description : conditionSetPlan .Description .ValueStringPointer (),
113- Type : & conditionSetType ,
114- Conditions : conditions ,
110+ Key : conditionSetPlan .Key .ValueString (),
111+ Name : conditionSetPlan .Name .ValueString (),
112+ Type : & conditionSetType ,
113+ Conditions : conditions ,
114+ }
115+
116+ // Only set description if it's not null and not empty
117+ if ! conditionSetPlan .Description .IsNull () && conditionSetPlan .Description .ValueString () != "" {
118+ conditionSetCreate .Description = conditionSetPlan .Description .ValueStringPointer ()
115119 }
116120
117121 if ! conditionSetPlan .Resource .IsNull () {
@@ -126,7 +130,8 @@ func (c *ConditionSetClient) Create(ctx context.Context, conditionSetType models
126130 conditionSetCreate .ResourceId = & resourceId
127131 }
128132
129- if ! conditionSetPlan .ParentId .IsNull () {
133+ // Only set parent_id if it's not null and not empty
134+ if ! conditionSetPlan .ParentId .IsNull () && conditionSetPlan .ParentId .ValueString () != "" {
130135 var parentId models.ParentId
131136 parentIdStr := conditionSetPlan .ParentId .ValueString ()
132137 err = json .Unmarshal ([]byte (fmt .Sprintf ("\" %s\" " , parentIdStr )), & parentId )
@@ -144,9 +149,11 @@ func (c *ConditionSetClient) Create(ctx context.Context, conditionSetType models
144149 return err
145150 }
146151
147- // Only update description if API returns one, otherwise preserve the plan value
152+ // Set description from API response, or null if API returns null
148153 if conditionSetRead .Description != nil {
149154 conditionSetPlan .Description = types .StringPointerValue (conditionSetRead .Description )
155+ } else {
156+ conditionSetPlan .Description = types .StringPointerValue (nil )
150157 }
151158 // Handle parent_id from API response
152159 if conditionSetRead .ParentId != nil {
@@ -185,7 +192,8 @@ func (c *ConditionSetClient) Update(ctx context.Context, conditionSetPlan *Condi
185192 Conditions : conditions ,
186193 }
187194
188- if ! conditionSetPlan .ParentId .IsNull () {
195+ // Only set parent_id if it's not null and not empty
196+ if ! conditionSetPlan .ParentId .IsNull () && conditionSetPlan .ParentId .ValueString () != "" {
189197 var parentId models.ParentId
190198 parentIdStr := conditionSetPlan .ParentId .ValueString ()
191199 err = json .Unmarshal ([]byte (fmt .Sprintf ("\" %s\" " , parentIdStr )), & parentId )
@@ -210,9 +218,11 @@ func (c *ConditionSetClient) Update(ctx context.Context, conditionSetPlan *Condi
210218 }
211219
212220 conditionSetPlan .Name = types .StringValue (conditionSetRead .Name )
213- // Only update description if API returns one, otherwise preserve the plan value
221+ // Set description from API response, or null if API returns null
214222 if conditionSetRead .Description != nil {
215223 conditionSetPlan .Description = types .StringPointerValue (conditionSetRead .Description )
224+ } else {
225+ conditionSetPlan .Description = types .StringPointerValue (nil )
216226 }
217227 // Handle parent_id from API response
218228 if conditionSetRead .ParentId != nil {
0 commit comments