- Notifications
You must be signed in to change notification settings - Fork 266
Fix output malformed when wrapper enabled #367
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
Conversation
bb87bf5 to 0d847da Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there @OJFord 👋🏻 , thanks for the PR.
Trying to digest these issues and your PR. After taking a glance into the underlying @actions/exec package, it looks like currently, the package outputs to STDOUT by default... however, that output seems to also include a printing of the command it's running (odd default behavior!).
As a result, running your PR'd changes just outputs the STDOUT twice. I ran your PR's changes against my own repo action as a test if you'd like to see the output:
Looking at @actions/exec options, we may be able to suppress the default STDOUT writing with the silent option, then use your changes here to output the correct STDOUT/STDERR.
| Thanks! Will have a look. |
0d847da to f28aa14 Compare f28aa14 to adb3460 Compare | Thanks for that - I've worked around it as you suggested and proposed a fix (write it to stderr, not stdout) upstream. I've updated the commit message/PR description to reflect that too, sorry that slightly breaks the context of your comment. |
Presently using a command such as `terraform output -json | jq` does not work with the wrapper enabled, as it is by default. In order to consume terraform's output having set it up with this Action, it is necessary either to disable the wrapper (`with: terraform_wrapper: false`) or run it in its own Actions step with an explicit `id` (e.g. `id: foo`) so that it can be referred to and consumed (`${{steps.foo.outputs.stdout}}` et al.) in later steps. This seems to be the result of much confusion (issues passim) and is not at all easy (hashicorp#338) to debug/diagnose and come to the realisation that it's due to the wrapper, or even that such a thing exists. @austinvalle identified the issue as being due to the `@actions/exec` package writing the spawned command to stdout (along with then its actual stdout). This has previously been reported upstream in actions/toolkit#649; I've proposed actions/toolkit#1573 to fix it. This commit aims to address the issue for `setup-terraform` in the meantime by silencing `@actions/exec` and then writing out to stdout & stderr from the listener buffers, which it writes to without this additional logging. Closes hashicorp#20, hashicorp#80, hashicorp#85, hashicorp#149, hashicorp#338, and probably more. adb3460 to ac70dfc Compare | Alright, more weirdness coming from the wrapper (some of this is mentioned in the GH issues linked in the description). So I added a simple test with JQ to this PR so we can prove the STDOUT is being printed without any unwanted characters. You can see with the wrapper, we still get an error (although JQ still processes the command properly), however the actual output looks correct 🤔 (vs. the non-wrapper equivalent that is successful). After some debugging and looking through the linked issues, I found that there actually is hidden output because of the $ terraform output -json { "pet_name": { "sensitive": false, "type": "string", "value": "balanced-marmot" } } ::debug::Terraform exited with code 0. ::debug::stdout: {%0A "pet_name": {%0A "sensitive": false,%0A "type": "string",%0A "value": "balanced-marmot"%0A }%0A}%0A ::debug::stderr: ::debug::exitcode: 0These |
austinvalle left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this @OJFord! Will look to release this with v3.0.0 next week!
| I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |


Presently using a command such as
terraform output -json | jqdoes not work with the wrapper enabled, as it is by default.In order to consume terraform's output having set it up with this Action, it is necessary either to disable the wrapper (
with: terraform_wrapper: false) or run it in its own Actions step with an explicitid(e.g.id: foo) so that it can be referred to and consumed (${{steps.foo.outputs.stdout}}et al.) in later steps.This seems to be the result of much confusion (issues passim) and is not at all easy (#338) to debug/diagnose and come to the realisation that it's due to the wrapper, or even that such a thing exists.
@austinvalle identified the issue as being due to the
@actions/execpackage writing the spawned command to stdout (along with then its actual stdout). This has previously been reported upstream in actions/toolkit#649; I've proposed actions/toolkit#1573 to fix it.This commit aims to address the issue for
setup-terraformin the meantime by silencing@actions/execand then writing out to stdout & stderr from the listener buffers, which it writes to without this additional logging.Closes #20, #80, #85, #149, #338, #42, #167