Skip to content

querycheck.ExpectResourceKnownValues: Improve readability when there are multiple errors#622

Open
gdavison wants to merge 2 commits intohashicorp:mainfrom
gdavison:f-querycheck-separate-multiple-resource-known-value
Open

querycheck.ExpectResourceKnownValues: Improve readability when there are multiple errors#622
gdavison wants to merge 2 commits intohashicorp:mainfrom
gdavison:f-querycheck-separate-multiple-resource-known-value

Conversation

@gdavison
Copy link
Contributor

Description

When using querycheck.ExpectResourceKnownValues, the current error results when there are multiple resource value errors look something like the following:

=== CONT  TestAccELBV2LoadBalancer_List_includeResource
    load_balancer_list_test.go:95: Step 2/2 error running query checks: the following errors were found while checking values: error checking value for attribute at path: access_logs for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected 0 elements for ListSizeExact check, got 1 element; error checking value for attribute at path: arn_suffix for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected regex match ^[a-z0-9]{16}$ for StringRegexp check, got: app/tf-acc-testbkbacefzgcpvxoof-0/151f26db099a6462; error checking value for attribute at path: connection_logs for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected 0 elements for ListSizeExact check, got 1 element; error checking value for attribute at path: dns_record_client_routing_policy for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected non-nil value for NotNull check, got: <nil>; error checking value for attribute at path: health_check_logs for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected 0 elements for ListSizeExact check, got 1 element; error checking value for attribute at path: id for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected value tf-acc-testbkbacefzgcpvxoof for StringExact check, got: arn:aws:elasticloadbalancing:us-west-2:200536214716:loadbalancer/app/tf-acc-testbkbacefzgcpvxoof-0/151f26db099a6462; error checking value for attribute at path: idle_timeout for resource with identity {%!s(func() map[string]knownvalue.Check=0x11715a730)}, err: expected value 60 for Int32Exact check, got: 30; 

Individual errors are separated by ; . This can be hard to read.

The function errors.Join separates individual errors using a newline. The same errors would be:

=== CONT  TestAccELBV2LoadBalancer_List_includeResource
    load_balancer_list_test.go:95: Step 2/2 error running query checks: the following errors were found while checking values: error checking value for attribute at path: access_logs for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected 0 elements for ListSizeExact check, got 1 element
        error checking value for attribute at path: arn_suffix for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected regex match ^[a-z0-9]{16}$ for StringRegexp check, got: app/tf-acc-testrb9x7tpomjapzd8z-0/de66aba63478903c
        error checking value for attribute at path: connection_logs for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected 0 elements for ListSizeExact check, got 1 element
        error checking value for attribute at path: dns_record_client_routing_policy for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected non-nil value for NotNull check, got: <nil>
        error checking value for attribute at path: health_check_logs for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected 0 elements for ListSizeExact check, got 1 element
        error checking value for attribute at path: id for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected value tf-acc-testrb9x7tpomjapzd8z for StringExact check, got: arn:aws:elasticloadbalancing:us-west-2:200536214716:loadbalancer/app/tf-acc-testrb9x7tpomjapzd8z-0/de66aba63478903c
        error checking value for attribute at path: idle_timeout for resource with identity {%!s(func() map[string]knownvalue.Check=0x11af9c170)}, err: expected value 60 for Int32Exact check, got: 30

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

@gdavison gdavison requested a review from a team as a code owner February 25, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant