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: don't use existing context when evaluating resources, data or provider blocks #3075

Merged
merged 1 commit into from
May 24, 2024

Conversation

aliscott
Copy link
Member

The SetByDot function handles the merging anyway, so we don't need to pull out the existing values. I've left the old functionality in the evaluateResource and evaluatorProvider functions because the legacy evaluator needs it.

This also fixes an issue where the data blocks were using e.ctx.Get(b.TypeLabel()) which was getting the wrong context. The correct functionality would have been to use e.ctx.Get("data"). Otherwise, this caused issues where the type of a data block matched the name of a resource, e.g. data.aws_lb.anything and aws_lb.aws_lb. In this case it would pull the context of the resource, which could cause a panic if the resource had been expanded, because it would be an array instead of the expected map.

@aliscott aliscott self-assigned this May 23, 2024
@aliscott aliscott marked this pull request as ready for review May 23, 2024 18:30
@aliscott aliscott requested a review from hugorut May 23, 2024 18:31
Copy link
Contributor

@hugorut hugorut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

internal/hcl/graph_vertex_data.go Outdated Show resolved Hide resolved
…ovider blocks

The SetByDot function handles the merging anyway, so we don't need to pull out the existing values. I've left the old functionality in the `evaluateResource` and `evaluatorProvider` functions because the legacy evaluator needs it.

This also fixes an issue where the data blocks were using `e.ctx.Get(b.TypeLabel())` which was getting the wrong context. The correct functionality would have been to use `e.ctx.Get("data")`. Otherwise, this caused issues where the type of a data block matched the name of a resource, e.g. `data.aws_lb.anything` and `aws_lb.aws_lb`. In this case it would pull the context of the resource, which could cause a panic if the resource had been expanded, because it would be an array instead of the expected map.
@aliscott aliscott merged commit f45e8fa into master May 24, 2024
8 of 10 checks passed
@aliscott aliscott deleted the fix/data-resource-context branch May 24, 2024 08:10
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.

2 participants