Skip to content

Commit ebce4ce

Browse files
authored
fix: check if owner groups exist before marshaling (#205)
1 parent 176fb6a commit ebce4ce

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

provider/workspace.go

+5-3
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)