Skip to content

Commit

Permalink
[HCP Vault Secrets] Fix panic on read errors (#751)
Browse files Browse the repository at this point in the history
* Fix segmentation fault for missing secrets

* changelog
  • Loading branch information
averche authored Feb 12, 2024
1 parent 6f90dae commit d58d335
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/751.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Fixing a panic on errors when opening secrets from HCP Vault Secrets.
```
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (r *resourceVaultsecretsSecret) Create(ctx context.Context, req resource.Cr

res, err := clients.CreateVaultSecretsAppSecret(ctx, r.client, loc, plan.AppName.ValueString(), plan.SecretName.ValueString(), plan.SecretValue.ValueString())
if err != nil {
resp.Diagnostics.AddError("Error creating Vault Secrets Secret", err.Error())
resp.Diagnostics.AddError("Error creating secret", err.Error())
return
}

Expand All @@ -145,7 +145,8 @@ func (r *resourceVaultsecretsSecret) Read(ctx context.Context, req resource.Read

res, err := clients.OpenVaultSecretsAppSecret(ctx, r.client, loc, state.AppName.ValueString(), state.SecretName.ValueString())
if err != nil {
resp.Diagnostics.AddError(err.Error(), "Unable to get secret")
resp.Diagnostics.AddError(err.Error(), "Error reading secret")
return
}

state.SecretValue = types.StringValue(res.Version.Value)
Expand Down

0 comments on commit d58d335

Please sign in to comment.