From ebce4cef4ec4324c021c096162249ad0397e47ab Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 3 Apr 2024 10:14:51 -0500 Subject: [PATCH] fix: check if owner groups exist before marshaling (#205) --- 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)