atlantis: v0.24.0 conftest regression: invalid character 't' after top-level value
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
- Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Overview of the Issue
After upgrading to v0.24.0, conftest policy checking results in this error: invalid character 't' after top-level value. Policy checking worked fine in v0.23.5 and lower.
Reproduction Steps
workflows:
init-plan-apply:
plan:
steps:
- init
- plan:
extra_args: ["-lock-timeout=300s"]
policy_check:
steps:
- show # this is the equivalent of `terraform show -json $PLANFILE > $SHOWFILE`
- run: >
conftest test -p ../../modules/aws/application/policies/ --all-namespaces $SHOWFILE
apply:
steps:
- init
- show # this is the equivalent of `terraform show -json $PLANFILE > $SHOWFILE`
- run: >
conftest test -p ../../modules/aws/application/policies/ --all-namespaces $SHOWFILE
- apply:
extra_args: ["-lock-timeout=300s"]
Logs
{
"caller": "terraform/terraform_client.go:422",
"json": {
"pull": "4478",
"repo": "SOME_COMPANY/devops"
},
"level": "info",
"msg": "Successfully ran \"/usr/local/bin/terraform show -json /home/atlantis/.atlantis/repos/SOME_COMPANY/devops/4478/default/terraform/SOME_COMPANY/environments/THIS_ENVIRONMENT/THIS_ENVIRONMENT-default.tfplan\" in \"/home/atlantis/.atlantis/repos/SOME_COMPANY/devops/4478/default/terraform/SOME_COMPANY/environments/THIS_ENVIRONMENT\"",
"ts": "2023-05-23T13:40:21.563Z"
}
{
"caller": "events/instrumented_project_command_runner.go:77",
"json": {
"pull": "4478",
"repo": "SOME_COMPANY/devops"
},
"level": "error",
"msg": "Error running policy check operation: invalid character 't' after top-level value",
"stacktrace": "github.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:77\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).PolicyCheck\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:42\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:48\ngithub.com/runatlantis/atlantis/server/events.(*PolicyCheckCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/policy_check_command_runner.go:65\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:282\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:290\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:298",
"ts": "2023-05-23T13:40:22.944Z"
}
{
"caller": "models/shell_command_runner.go:156",
"json": {
"pull": "4478",
"repo": "SOME_COMPANY/devops"
},
"level": "info",
"msg": "successfully ran \"conftest test -p ../../modules/aws/application/policies/ --all-namespaces $SHOWFILE\\n\" in \"/home/atlantis/.atlantis/repos/SOME_COMPANY/devops/4478/default/terraform/SOME_COMPANY/environments/THIS_ENVIRONMENT\"",
"ts": "2023-05-23T13:40:22.944Z"
}
Environment details
If not already included, please provide the following:
- Atlantis version: v0.24.0 (and v0.23.5 works fine)
- Deployment method: AWS ECS (Fargate)
- If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: NA
- Atlantis flags: We don’t specify any command for running the Atlantis server, so our usage of Atlantis would inherit whatever the default ENTRYPOINT is in the Docker image.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (21 by maintainers)
@pseudomorph - Yes, it happens on every run.
I just tested out your branch and that does indeed solve our issue running with above custom policy_check. It also blocks the 2*apply bug so users can no longer bypass conftest, which was our primary reason for upgrading.
In below screenshots “OPA policies can be found here: xxxxx” this is from run echo command between show and policy_check, so that also looks perfect from my point of view.
Passing:
Failing:

@nitrocode - I think I can put together a quick fix for output not getting parsed when custom run steps are used.
Further discussion is needed for whether custom conftest invocations should be supported, and if so, how.
I want to verify that my metric fix is not the one causing this issue. This is my first commit: 96cf38835e15cd2822739076bb3c9e540fa76f09
The bug was introduced in:
It doesn’t show up in d88857bb01a9515223d82d7d084b79581103271b which is the previous commit.