Skip to content

Commit 2f4fb1b

Browse files
authored
Fix panic reading project data source (#176)
Turns out git_comments in the response can be null, and this wasn't handled for the data_source. Can't test this effectively, as new projects _always_ have git_comments set, which is why this was missed. Closes #175
1 parent ef3f51d commit 2f4fb1b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

vercel/data_source_project.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,13 @@ func convertResponseToProjectDataSource(ctx context.Context, response client.Pro
314314
otherwise it causes issues with terraform thinking there are changes when there aren't. However,
315315
for the data source we always want to read the value */
316316
plan.Environment = types.SetValueMust(envVariableElemType, []attr.Value{})
317-
plan.GitComments = types.ObjectValueMust(gitCommentsAttrTypes, map[string]attr.Value{
318-
"on_pull_request": types.BoolValue(response.GitComments.OnPullRequest),
319-
"on_commit": types.BoolValue(response.GitComments.OnCommit),
320-
})
317+
plan.GitComments = types.ObjectNull(gitCommentsAttrTypes)
318+
if response.GitComments != nil {
319+
plan.GitComments = types.ObjectValueMust(gitCommentsAttrTypes, map[string]attr.Value{
320+
"on_pull_request": types.BoolValue(response.GitComments.OnPullRequest),
321+
"on_commit": types.BoolValue(response.GitComments.OnCommit),
322+
})
323+
}
321324
project, err := convertResponseToProject(ctx, response, plan, environmentVariables)
322325
if err != nil {
323326
return ProjectDataSource{}, err

0 commit comments

Comments
 (0)