fix(cloud): cloud backend rendering query warning diags (#38040)

prepare/1.15.0-alpha20260114
Michael Yocca 1 month ago committed by GitHub
parent 0b9a20c7c4
commit 810f497ecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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"

@ -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
}
}
}
}

@ -139,3 +139,42 @@ 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()
stream, close := terminal.StreamsForTesting(t)
b.renderer = &jsonformat.Renderer{
Streams: stream,
Colorize: mockColorize(),
}
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())
}
testOut := close(t)
output := testOut.Stdout()
// 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)
}
}

@ -0,0 +1 @@
resource "null_resource" "foo" {}

@ -0,0 +1,3 @@
list "concept_pet" "pets" {
provider = concept
}

@ -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":"Warning: Something went wrong","detail":"detail"},"type":"diagnostic"}
Loading…
Cancel
Save