Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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.14/BUG FIXES-20260108-114527.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: Fixes an issue where any warning diagnostics generated during terraform query execution failed to render in the cloud backend session
time: 2026-01-08T11:45:27.489784-08:00
custom:
Issue: "38040"
5 changes: 5 additions & 0 deletions internal/cloud/backend_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ func (b *Cloud) renderQueryRunLogs(ctx context.Context, op *backendrun.Operation
if result.Len() > 0 {
b.renderer.Streams.Println(result.String())
}
default:
err := b.renderer.RenderLog(log)
if err != nil {
return err
}
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions internal/cloud/backend_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,33 @@ list.concept_pet.pets id=legal-lamprey,legs=2 This is a legal-lamprey
t.Fatalf("unexpected error locking state after successful plan: %s", err.Error())
}
}

func TestCloud_queryJSONWithDiags(t *testing.T) {
b, bCleanup := testBackendWithName(t)
defer bCleanup()

op, configCleanup, done := testOperationQuery(t, "./testdata/query-json-diag")
defer configCleanup()
defer done(t)

op.Workspace = testBackendSingleWorkspaceName

mockSROWorkspace(t, b, op.Workspace)

run, err := b.Operation(context.Background(), op)
if err != nil {
t.Fatalf("error starting operation: %v", err)
}

<-run.Done()
if run.Result != backendrun.OperationSuccess {
t.Fatalf("operation failed: %s", b.CLI.(*cli.MockUi).ErrorWriter.String())
}

output := b.CLI.(*cli.MockUi).OutputWriter.String()
// Warning diagnostic message
testString := "Warning: Something went wrong"
if !strings.Contains(output, testString) {
t.Fatalf("Expected %q to contain %q but it did not", output, testString)
}
}
1 change: 1 addition & 0 deletions internal/cloud/testdata/query-json-diag/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resource "null_resource" "foo" {}
3 changes: 3 additions & 0 deletions internal/cloud/testdata/query-json-diag/main.tfquery.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
list "concept_pet" "pets" {
provider = concept
}
9 changes: 9 additions & 0 deletions internal/cloud/testdata/query-json-diag/query.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{"@level":"info","@message":"Terraform 1.14.0-dev","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.859531+02:00","terraform":"1.14.0-dev","type":"version","ui":"1.2"}
{"@level":"info","@message":"list.concept_pet.pets: Starting query...","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.954999+02:00","list_start":{"address":"list.concept_pet.pets","resource_type":"concept_pet"},"type":"list_start"}
{"@level":"info","@message":"list.concept_pet.pets: Result found","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955489+02:00","list_resource_found":{"address":"list.concept_pet.pets","display_name":"This is a large-roughy","identity":{"id":"large-roughy","legs":2},"resource_type":"concept_pet"},"type":"list_resource_found"}
{"@level":"info","@message":"list.concept_pet.pets: Result found","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955516+02:00","list_resource_found":{"address":"list.concept_pet.pets","display_name":"This is a able-werewolf","identity":{"id":"able-werewolf","legs":5},"resource_type":"concept_pet"},"type":"list_resource_found"}
{"@level":"info","@message":"list.concept_pet.pets: Result found","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955523+02:00","list_resource_found":{"address":"list.concept_pet.pets","display_name":"This is a complete-gannet","identity":{"id":"complete-gannet","legs":6},"resource_type":"concept_pet"},"type":"list_resource_found"}
{"@level":"info","@message":"list.concept_pet.pets: Result found","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955529+02:00","list_resource_found":{"address":"list.concept_pet.pets","display_name":"This is a charming-beagle","identity":{"id":"charming-beagle","legs":3},"resource_type":"concept_pet"},"type":"list_resource_found"}
{"@level":"info","@message":"list.concept_pet.pets: Result found","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955535+02:00","list_resource_found":{"address":"list.concept_pet.pets","display_name":"This is a legal-lamprey","identity":{"id":"legal-lamprey","legs":2},"resource_type":"concept_pet"},"type":"list_resource_found"}
{"@level":"info","@message":"list.concept_pet.pets: List complete","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955538+02:00","list_complete":{"address":"list.concept_pet.pets","resource_type":"concept_pet","total":5},"type":"list_complete"}
{"@level":"warn","@message":"Warning: Something went wrong","@module":"terraform.ui","@timestamp":"2025-08-29T14:07:26.955540+02:00"","diagnostic":{"severity":"warning","summary":"summary","detail":"detail"},"type":"diagnostic"}