From 309e575aae01e7f35d9c1021062457f4a6408075 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 3 Apr 2024 11:13:09 -0400 Subject: [PATCH] fix: check if owner groups exist before marshaling --- provider/workspace.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/provider/workspace.go b/provider/workspace.go index 1511d2b5..0e1abf97 100644 --- a/provider/workspace.go +++ b/provider/workspace.go @@ -39,9 +39,11 @@ func workspaceDataSource() *schema.Resource { ownerGroupsText := os.Getenv("CODER_WORKSPACE_OWNER_GROUPS") var ownerGroups []string - err := json.Unmarshal([]byte(ownerGroupsText), &ownerGroups) - if err != nil { - return diag.Errorf("couldn't parse owner groups %q", ownerGroupsText) + if ownerGroupsText != "" { + err := json.Unmarshal([]byte(ownerGroupsText), &ownerGroups) + if err != nil { + return diag.Errorf("couldn't parse owner groups %q", ownerGroupsText) + } } _ = rd.Set("owner_groups", ownerGroups)