Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/v1.13/BUG FIXES-20251009-144645.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: Fix crash when showing a cloud plan without having a cloud backend
time: 2025-10-09T14:46:45.59398+02:00
custom:
Issue: "37751"
2 changes: 1 addition & 1 deletion internal/cloud/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (b *Cloud) Configure(obj cty.Value) tfdiags.Diagnostics {
}

func (b *Cloud) AppName() string {
if isValidAppName(b.appName) {
if b != nil && isValidAppName(b.appName) {
return b.appName
}
return "HCP Terraform"
Expand Down
12 changes: 12 additions & 0 deletions internal/cloud/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,3 +1705,15 @@ func TestCloud_ServiceDiscoveryAliases(t *testing.T) {
t.Fatalf("expected 1 alias but got %d", len(aliases))
}
}

// When a user tries to view a cloud plan without having a cloud backend in their
// configuration, a call to AppName() would fail with a nil pointer exception
// See: https://github.com/hashicorp/terraform/issues/37748
func TestCloud_AppName_with_nil(t *testing.T) {
var backend *Cloud = nil

name := backend.AppName()
if name != "HCP Terraform" {
t.Fatalf("expected name to be HCP Terraform, got %q", name)
}
}