Skip to content

Reject obviously incorrect target_refs during plan validation #183

@JohannesRudolph

Description

@JohannesRudolph

I had this subtle bug today in my hcl

resource "meshstack_building_block_v2" "this" {
  spec = {
    building_block_definition_version_ref = module.resource_group.building_block_definition.version_ref

    display_name = "smoke-test-resource-group-${var.test_context.name_suffix}"
    target_ref = {
      kind = "meshTenant"
      name = var.test_context.fixtures.azure.mesh_tenant_id
    }

I got an error only during apply


│ Error: Error creating building block
│ 
│   with meshstack_building_block_v2.this,
│   on main.tf line 49, in resource "meshstack_building_block_v2" "this":
│   49: resource "meshstack_building_block_v2" "this" {
│ 
│ Could not create building block, unexpected error: http error 400, response '{"message":"Could not read request body: value failed for JSON property uuid due to missing (therefore NULL) value for
│ creator parameter uuid which is a non-nullable type","errorCode":"HttpMessageNotReadable","errorId":"DOSQIay5vw"}'

I should have used target_ref.uuid instead of target_ref.name. We know what the valid combinations are (and we can even validate that a uuid is a proper uuid). It would be very helpful if this was already a schema/plan validation failure instead of a runtime error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions