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

OPA fmt in OPA 0.58+ improperly stripping assignment and term from chained rules #6467

Closed
grantlanglois opened this issue Dec 9, 2023 · 1 comment · Fixed by #6468
Closed
Labels

Comments

@grantlanglois
Copy link

grantlanglois commented Dec 9, 2023

Short description

OPA 0.58.0, specifically #6323 appears to have introduced what I believe to be a regression in opa fmt where the assignment operator and term in the rule heads of chain rules are removed from the re-written rule head.

Steps To Reproduce

In OPA 0.58+ the OPA fmt'ing the following:

instances_or_clusters[id] = ret {
  instances = input.resources["aws_db_instance"]
  ret = instances[id]
} {
  clusters = input.resources["aws_rds_cluster"]
  ret = clusters[id]
}

Results in the following:

instances_or_clusters[id] = ret if {
	instances = input.resources.aws_db_instance
	ret = instances[id]
}

instances_or_clusters[id] if {
	clusters = input.resources.aws_rds_cluster
	ret = clusters[id]
}

Expected behavior

instances_or_clusters[id] = ret if {
	instances = input.resources.aws_db_instance
	ret = instances[id]
}

instances_or_clusters[id] = ret if {
	clusters = input.resources.aws_rds_cluster
	ret = clusters[id]
}

Additional context

@anderseknert
Copy link
Member

Thanks for the bug report, @grantlanglois! That does look like an oversight on my part. I'll take a look.

anderseknert added a commit to anderseknert/opa that referenced this issue Dec 11, 2023
Fixes open-policy-agent#6467

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit to anderseknert/opa that referenced this issue Dec 11, 2023
And add test cases using chained bodies, as that would previously
get mistaken for implicit return without chaining.

Fixes open-policy-agent#6467

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Dec 11, 2023
And add test cases using chained bodies, as that would previously
get mistaken for implicit return without chaining.

Fixes #6467

Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants