@@ -84,6 +84,10 @@ func (r *ZeroTrustAccessPolicyResource) Create(ctx context.Context, req resource
84
84
resp .Diagnostics .AddError ("failed to make http request" , err .Error ())
85
85
return
86
86
}
87
+ if res == nil || res .Body == nil {
88
+ resp .Diagnostics .AddError ("failed to read response" , "Response or response body is nil" )
89
+ return
90
+ }
87
91
bytes , _ := io .ReadAll (res .Body )
88
92
err = apijson .UnmarshalComputed (bytes , & env )
89
93
if err != nil {
@@ -133,6 +137,10 @@ func (r *ZeroTrustAccessPolicyResource) Update(ctx context.Context, req resource
133
137
resp .Diagnostics .AddError ("failed to make http request" , err .Error ())
134
138
return
135
139
}
140
+ if res == nil || res .Body == nil {
141
+ resp .Diagnostics .AddError ("failed to read response" , "Response or response body is nil" )
142
+ return
143
+ }
136
144
bytes , _ := io .ReadAll (res .Body )
137
145
err = apijson .UnmarshalComputed (bytes , & env )
138
146
if err != nil {
@@ -180,6 +188,10 @@ func (r *ZeroTrustAccessPolicyResource) Read(ctx context.Context, req resource.R
180
188
resp .Diagnostics .AddError ("failed to make http request" , err .Error ())
181
189
return
182
190
}
191
+ if res == nil || res .Body == nil {
192
+ resp .Diagnostics .AddError ("failed to read response" , "Response or response body is nil" )
193
+ return
194
+ }
183
195
bytes , _ := io .ReadAll (res .Body )
184
196
err = apijson .Unmarshal (bytes , & env )
185
197
if err != nil {
@@ -258,6 +270,10 @@ func (r *ZeroTrustAccessPolicyResource) ImportState(ctx context.Context, req res
258
270
resp .Diagnostics .AddError ("failed to make http request" , err .Error ())
259
271
return
260
272
}
273
+ if res == nil || res .Body == nil {
274
+ resp .Diagnostics .AddError ("failed to read response" , "Response or response body is nil" )
275
+ return
276
+ }
261
277
bytes , _ := io .ReadAll (res .Body )
262
278
err = apijson .Unmarshal (bytes , & env )
263
279
if err != nil {
@@ -266,6 +282,9 @@ func (r *ZeroTrustAccessPolicyResource) ImportState(ctx context.Context, req res
266
282
}
267
283
data = & env .Result
268
284
285
+ // Apply import-specific normalizations to handle API omissions
286
+ resp .Diagnostics .Append (normalizeImportZeroTrustAccessPolicyAPIData (ctx , data )... )
287
+
269
288
resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
270
289
}
271
290
0 commit comments