Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix contains on dict type #5138

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

🐛 fix contains on dict type #5138

wants to merge 3 commits into from

Conversation

arlimus
Copy link
Member

@arlimus arlimus commented Jan 29, 2025

We are experiencing issues where two dict types being compared don't come up with the right results. Here is an example I ran to produce this:

> region = terraform.plan.variables.where( name == "gcp_region" ).first.value;
  terraform.plan.variables.where(name == "service_vpc_connector").all(v: v.value.contains(region) )
[failed] [].all()
  actual:   [
    0: terraform.plan.variable value="projects/prj-pp-gen-preprod-net-acc7/locations/us-central1/connectors/preprod-gen-central1-02" name="service_vpc_connector"
  ]

As you can see above we are looking at the value of the varaible, which clearly is set to the region but doesn't come up. If we print out the variables individually, it all comes out correctly.

The problem is that the string comparison doesn't work when we work with dict types because in that example we have to create code that has to with with arbitrary content and work with filtering on another dict.

This PR fixes the issue.

> region = terraform.plan.variables.where( name == "gcp_region" ).first.value;
  terraform.plan.variables.where(name == "service_vpc_connector").all(v: v.value.contains(region) )
[ok] value: true

CC @scottford-io

We are experiencing issues where two `dict` types being compared don't
come up with the right results. Here is an example I ran to produce
this:

```coffee
> region = terraform.plan.variables.where( name == "gcp_region" ).first.value;
  terraform.plan.variables.where(name == "service_vpc_connector").all(v: v.value.contains(region) )
[failed] [].all()
  actual:   [
    0: terraform.plan.variable value="projects/prj-pp-gen-preprod-net-acc7/locations/us-central1/connectors/preprod-gen-central1-02" name="service_vpc_connector"
  ]
```

As you can see above we are looking at the `value` of the varaible,
which clearly is set to the region but doesn't come up. If we print out
the variables individually, it all comes out correctly.

The problem is that the string comparison doesn't work when we work with
`dict` types because in that example we have to create code that has to
with with arbitrary content and work with filtering on another `dict`.

This PR fixes the issue.

```coffee
> region = terraform.plan.variables.where( name == "gcp_region" ).first.value;
  terraform.plan.variables.where(name == "service_vpc_connector").all(v: v.value.contains(region) )
[ok] value: true
```
Copy link
Contributor

github-actions bot commented Jan 29, 2025

Test Results

3 212 tests  +6   3 208 ✅ +6   1m 52s ⏱️ -14s
  385 suites ±0       4 💤 ±0 
   29 files   ±0       0 ❌ ±0 

Results for commit 961b1af. ± Comparison against base commit ec10d80.

♻️ This comment has been updated with latest results.

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