File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ func (b *Cloud) Configure(obj cty.Value) tfdiags.Diagnostics {
437437}
438438
439439func (b * Cloud ) AppName () string {
440- if isValidAppName (b .appName ) {
440+ if b != nil && isValidAppName (b .appName ) {
441441 return b .appName
442442 }
443443 return "HCP Terraform"
Original file line number Diff line number Diff line change @@ -1705,3 +1705,15 @@ func TestCloud_ServiceDiscoveryAliases(t *testing.T) {
17051705 t .Fatalf ("expected 1 alias but got %d" , len (aliases ))
17061706 }
17071707}
1708+
1709+ // When a user tries to view a cloud plan without having a cloud backend in their
1710+ // configuration, a call to AppName() would fail with a nil pointer exception
1711+ // See: https://github.com/hashicorp/terraform/issues/37748
1712+ func TestCloud_AppName_with_nil (t * testing.T ) {
1713+ var backend * Cloud = nil
1714+
1715+ name := backend .AppName ()
1716+ if name != "HCP Terraform" {
1717+ t .Fatalf ("expected name to be HCP Terraform, got %q" , name )
1718+ }
1719+ }
You can’t perform that action at this time.
0 commit comments