Skip to content

Commit 8e87274

Browse files
authored
Fix issue where null values are incorrectly coerced to empty lists (#284)
This makes it appear that there are changes to be made to the resource, as it's trying to do [] => null, but realistically they are the same.
1 parent 61ab271 commit 8e87274

2 files changed

+14
-7
lines changed

vercel/resource_shared_environment_variable_project_link.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type SharedEnvironmentVariableProjectLink struct {
8282
TeamID types.String `tfsdk:"team_id"`
8383
}
8484

85-
func (e *SharedEnvironmentVariableProjectLink) toUpdateSharedEnvironmentVariableRequest(ctx context.Context, link bool) (req client.UpdateSharedEnvironmentVariableRequest, ok bool) {
85+
func (e *SharedEnvironmentVariableProjectLink) toUpdateSharedEnvironmentVariableRequest(link bool) (req client.UpdateSharedEnvironmentVariableRequest, ok bool) {
8686
upd := client.UpdateSharedEnvironmentVariableRequestProjectIDUpdates{}
8787

8888
if link {
@@ -106,7 +106,7 @@ func (r *sharedEnvironmentVariableProjectLinkResource) Create(ctx context.Contex
106106
return
107107
}
108108

109-
request, ok := plan.toUpdateSharedEnvironmentVariableRequest(ctx, true)
109+
request, ok := plan.toUpdateSharedEnvironmentVariableRequest(true)
110110
if !ok {
111111
return
112112
}
@@ -194,7 +194,7 @@ func (r *sharedEnvironmentVariableProjectLinkResource) Delete(ctx context.Contex
194194
return
195195
}
196196

197-
request, ok := plan.toUpdateSharedEnvironmentVariableRequest(ctx, false)
197+
request, ok := plan.toUpdateSharedEnvironmentVariableRequest(false)
198198
if !ok {
199199
return
200200
}

vercel/resource_team_member.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,18 @@ func convertResponseToTeamMember(response client.TeamMember, plan TeamMember) Te
316316
))
317317
}
318318
projects := types.SetValueMust(projectsElemType, projectsAttrs)
319+
if len(projectsAttrs) == 0 {
320+
projects = types.SetNull(projectsElemType)
321+
}
319322

320323
var ags []attr.Value
321324
for _, ag := range response.AccessGroups {
322325
ags = append(ags, types.StringValue(ag.ID))
323326
}
324327
accessGroups := types.SetValueMust(types.StringType, ags)
328+
if len(ags) == 0 {
329+
accessGroups = types.SetNull(types.StringType)
330+
}
325331

326332
teamMember := TeamMember{
327333
UserID: types.StringValue(response.UserID),
@@ -448,10 +454,11 @@ func (r *teamMemberResource) Read(ctx context.Context, req resource.ReadRequest,
448454
TeamID: state.TeamID.ValueString(),
449455
UserID: state.UserID.ValueString(),
450456
})
451-
tflog.Error(ctx, "Read team member", map[string]any{
452-
"team_id": state.TeamID.ValueString(),
453-
"user_id": state.UserID.ValueString(),
454-
"err": err,
457+
tflog.Info(ctx, "Read team member", map[string]any{
458+
"team_id": state.TeamID.ValueString(),
459+
"user_id": state.UserID.ValueString(),
460+
"err": err,
461+
"response": response,
455462
})
456463
if client.NotFound(err) {
457464
resp.State.RemoveResource(ctx)

0 commit comments

Comments
 (0)