Skip to content

Commit 29c9f93

Browse files
committed
fix: return empty list when branching is disabled
1 parent ca68e2e commit 29c9f93

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/provider/branch_data_source.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package provider
66
import (
77
"context"
88
"fmt"
9+
"net/http"
910

1011
"github.com/hashicorp/terraform-plugin-framework/datasource"
1112
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -110,6 +111,10 @@ func (d *BranchDataSource) Read(ctx context.Context, req datasource.ReadRequest,
110111
resp.Diagnostics.AddError("Client Error", msg)
111112
return
112113
}
114+
// Create an empty array if branching is disabled
115+
if httpResp.StatusCode() == http.StatusUnprocessableEntity {
116+
httpResp.JSON200 = &[]api.BranchResponse{}
117+
}
113118
if httpResp.JSON200 == nil {
114119
msg := fmt.Sprintf("Unable to read branch, got status %d: %s", httpResp.StatusCode(), httpResp.Body)
115120
resp.Diagnostics.AddError("Client Error", msg)

0 commit comments

Comments
 (0)