Skip to content

Commit 1e880cb

Browse files
Copilotmawasilemattdot
authored
Fix missing return statements after error handling in datasources (#827)
* Initial plan for issue * Fix missing return statements after error handling in three datasources Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> * Add changelog entry for error handling fixes Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com> Co-authored-by: Matt Dotson <mattdot@users.noreply.github.com>
1 parent f986ba0 commit 1e880cb

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: fixed
2+
body: Fixed missing return statements after error handling in three datasources to prevent potential panics and undefined behavior
3+
time: 2025-06-04T17:50:56.587490569Z
4+
custom:
5+
Issue: "814"

internal/services/application/datasource_tenant_application_packages.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ func (d *TenantApplicationPackagesDataSource) Read(ctx context.Context, req data
171171
defer exitContext()
172172

173173
var state TenantApplicationPackagesListDataSourceModel
174-
resp.State.Get(ctx, &state)
174+
diags := resp.State.Get(ctx, &state)
175+
resp.Diagnostics.Append(diags...)
176+
if resp.Diagnostics.HasError() {
177+
return
178+
}
175179

176180
state.Name = types.StringValue(state.Name.ValueString())
177181
state.PublisherName = types.StringValue(state.PublisherName.ValueString())
@@ -213,7 +217,7 @@ func (d *TenantApplicationPackagesDataSource) Read(ctx context.Context, req data
213217
state.Applications = append(state.Applications, app)
214218
}
215219

216-
diags := resp.State.Set(ctx, &state)
220+
diags = resp.State.Set(ctx, &state)
217221

218222
resp.Diagnostics.Append(diags...)
219223
if resp.Diagnostics.HasError() {

internal/services/connectors/datasource_connectors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ func (d *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp
123123
connectors, err := d.ConnectorsClient.GetConnectors(ctx)
124124
if err != nil {
125125
resp.Diagnostics.AddError(fmt.Sprintf("Client error when reading %s", d.FullTypeName()), fmt.Errorf("error occurred: %w", err).Error())
126+
return
126127
}
127128

128129
for _, connector := range connectors {

internal/services/solution/datasource_solutions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (d *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp
134134
dvExits, err := d.SolutionClient.DataverseExists(ctx, state.EnvironmentId.ValueString())
135135
if err != nil {
136136
resp.Diagnostics.AddError(fmt.Sprintf("Client error when checking if Dataverse exists in environment '%s'", state.EnvironmentId.ValueString()), err.Error())
137+
return
137138
}
138139

139140
if !dvExits {

0 commit comments

Comments
 (0)