Skip to content

Commit 309e575

Browse files
committed
fix: check if owner groups exist before marshaling
1 parent 176fb6a commit 309e575

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

provider/workspace.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ func workspaceDataSource() *schema.Resource {
3939

4040
ownerGroupsText := os.Getenv("CODER_WORKSPACE_OWNER_GROUPS")
4141
var ownerGroups []string
42-
err := json.Unmarshal([]byte(ownerGroupsText), &ownerGroups)
43-
if err != nil {
44-
return diag.Errorf("couldn't parse owner groups %q", ownerGroupsText)
42+
if ownerGroupsText != "" {
43+
err := json.Unmarshal([]byte(ownerGroupsText), &ownerGroups)
44+
if err != nil {
45+
return diag.Errorf("couldn't parse owner groups %q", ownerGroupsText)
46+
}
4547
}
4648
_ = rd.Set("owner_groups", ownerGroups)
4749

0 commit comments

Comments
 (0)