-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 eval cant parse json file when it used in GitHub Actions. But locally it works. #5619
Comments
@vladimirpodr it could be that in the pipeline OPA does not see the input as you expect it to? What happens if you run locally with an empty input file for example. How did you set this up? Here's a reference to setup OPA cli in GHA if it helps. |
|
@ashutosh-narkar I tested with different environments the order of the next commands:
|
In your GitHub runner, what does this output?
FWIW, we run |
Hi @anderseknert ! |
Hey @vladimirpodr 👋 That doesn't look like the command I asked about though? I literally just want to see what OPA thinks the
|
Hey @anderseknert ! Oh, sorry))
|
Thanks Vladimir. That is indeed truly mysterious 🕵🏻♂️ I'm afraid I don't know what could be going on here. I don't suppose the code is public? If not, perhaps we could try and reproduce this in as minimal example as possible? I.e. just copy the tfplan file to some public repo and setup a simple GHA flow there? Or if you could try with another tfplan file, possibly with only a tiny little change? |
I'm facing the same situation. |
If anyone is able to provide a link to a repo where this is reproducible, that would be helpful. |
Did anyone manage to make any findings on this? |
I'm having a similar problem; any advice from anyone? |
Nothing yet :/ If anyone is able to reproduce this in a public repo, do let us know! |
On GitHub - https://github.com/actions/runner-images/tree/main/images, I have seen there were few updates on the runner images and now its working fine. |
That's good news, @mkurimeti . Did you have to do anything in order to update the runner? |
Nope, I haven't made any changes on my end; instead, the community in general has made all the fixes. |
Thanks @mkurimeti 👍 @vladimirpodr @igoritos22 have you seen this fixed by recent updates too? |
Closing due to inactivity. Let me know if anyone is experiencing this still with the latest versions of the runner, and I'll have it re-opened. |
@anderseknert To be brief, this isn't really an To determine this, I inspected our self-hosted runner's filesystem directly while a Terraform-related $ cat tfplan.json
[command]/runner/_work/_temp/e16010ee-5ac0-417f-8ffe-7aab4de2e9a0/terraform-bin show -json tfplan
...
::debug::stderr:
::debug::exitcode: 0 The terraform show -json tfplan > tfplan.json I believe this extra metadata is being added by the Later, when this file is provided as input to $ echo -e '[command]qwerty\n{}' | opa eval -I -f pretty input
[
"command"
] The solution here is to ensure the I am not sure if it is worth including this somewhere in the Open Policy Agent docs. In any case, I hope this helps someone in the future! |
Stellar research! That sounds like a very plausible explanation. While it would be a little unusal to point this out in docs that have nothing to do with GitHub Actions, I think a note might be warranted given how that's likely a common way to evaluate these plans. Would you like to submit a PR for the docs? |
Thank you for your kind words! As a small addendum, I did create a reproduction example here. In summary, this is indeed caused by the I agree that this would feel somewhat out of place in OPA's Terraform documentation when it is isolated to GitHub Actions. Might I make a suggestion? This note might be better placed in the open-policy-agent/setup-opa documentation. If you agree, I don't mind submitting a PR to create a "Troubleshooting" section that includes this as its first entry. |
Please do! 👍 |
Short description
I evaluate OPA policy to find the Azure resources without the required tags. Locally it works and outputs non-compliant resources. But when I try to evaluate the policy in the GitHub Actions pipeline - the output is empty. I rechecked everything: local and 'in pipeline' configs, versions are the same, all files exist, permissions, etc. In debug mode, I see that "in pipeline" OPA replaces input data with a simple "command" string.
Config:
Local and "in pipeline" OPA version - 0.48.0
Local machine - MacOS Ventura
Pipeline runner image based on - Ubuntu 22.04
OPA policy:
I run the next commands:
Local output:
In pipeline output:
Local debug:
In pipeline debug:
And, again, all needed files are in place, OPA version is the same. Locally it works but doesn't work in GitHub Actions Pipeline
The text was updated successfully, but these errors were encountered: