You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to comment on a PR via a workflow and keep getting this exception:
SyntaxError: Unexpected token 'var'
at new AsyncFunction (<anonymous>)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:4942:56)
at main (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:4997:26)
at Module.272 (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:4981:1)
Error: Unhandled error: SyntaxError: Unexpected token 'var'
at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:24:31)
at startup (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:43:19)
at /home/runner/work/_actions/actions/github-script/v5/dist/index.js:49:18
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v5/dist/index.js:52:10)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
Ok, I think the actual problem is with using a multiline output from a previous step's stdout as the body in createComment.
The problem is trying to make hashicorp/setup-terraform work with github-script@v5 and github.rest.issues.createComment. There is an example in the readme, but it is against actions/github-script@0.9.0 https://github.com/hashicorp/setup-terraform
Ok, I think the actual problem is with using a multiline output from a previous step's stdout as the body in createComment.
If you need to pass into multi-line outputs into the script block, you'll likely need to pass those values in as environment variables. Otherwise, newlines will be interpreted literally in the script and won't be valid JavaScript.
Reacted by Tim DuBois, Ravindu Rathugama, James Sumners, Michael Nguyen, 최병욱, Luiz Lelis, cole-nayya, Léo Meira Vital, Yosuke Obata, Ui2 Simon and 3 more
I am having this issue where the error message is:
SyntaxError: Invalid or unexpected token
at new AsyncFunction (<anonymous>)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:4797:16)
...
Going to close this issue out. If anyone sees an error like this, it usually means that the JavaScript is invalid in some way.
Usually this occurs when using the Actions expression syntax (${{ }}) in input a value that's then interpreted by the action as invalid JavaScript (ex. newlines, semi-colons, quotes, etc).
The workaround is to process this input indirectly, rather than inserting it directly into your script. This can be done by writing it to a file or using an env variable and reading it with process.env, see #220 (comment)
Feel free to open a new issue if you're still having issues after trying those workarounds.
Activity
joshmgross commentedon Dec 8, 2021
👋 Hey @tjbaker
What event is this workflow triggering on?
It's possible that
context.issue.numberisn't valid.If it's helpful, you can print out the full
context.issue:tjbaker commentedon Dec 8, 2021
It is triggered on pull_request
I can't try the additional debugging just yet...
tjbaker commentedon Dec 9, 2021
Ok, I think the actual problem is with using a multiline output from a previous step's stdout as the body in createComment.
The problem is trying to make hashicorp/setup-terraform work with github-script@v5 and github.rest.issues.createComment. There is an example in the readme, but it is against actions/github-script@0.9.0
https://github.com/hashicorp/setup-terraform
cemo commentedon Jan 7, 2022
@tjbaker did you resolve your issue?
joshmgross commentedon Jan 7, 2022
If you need to pass into multi-line outputs into the
scriptblock, you'll likely need to pass those values in as environment variables. Otherwise, newlines will be interpreted literally in the script and won't be valid JavaScript.Example:
jsumners commentedon Feb 15, 2022
I am having this issue where the error message is:
My step looks like:
Where
steps.get_data.outputs.resultis a large JSON object with formatting.joshmgross commentedon Feb 15, 2022
@jsumners are you able to pass that JSON object as an environment variable instead?
jsumners commentedon Feb 15, 2022
No. I moved on to writing the data to a file with JavaScript and then
curl -X POST ... -d @the.filein order to get around this problem.joshmgross commentedon Feb 15, 2022
Going to close this issue out. If anyone sees an error like this, it usually means that the JavaScript is invalid in some way.
Usually this occurs when using the Actions expression syntax (
${{ }}) in input a value that's then interpreted by the action as invalid JavaScript (ex. newlines, semi-colons, quotes, etc).The workaround is to process this input indirectly, rather than inserting it directly into your script. This can be done by writing it to a file or using an
envvariable and reading it withprocess.env, see #220 (comment)Feel free to open a new issue if you're still having issues after trying those workarounds.
salecharohit commentedon Feb 19, 2022
So I encountered this same issue and was able to resolve it using below as per @joshmgross's recommendation
.github: workflows: Introduce a new dependabot pip-compile workflow
.github: workflows: Introduce a new dependabot pip-compile workflow
.github: workflows: Introduce a new dependabot pip-compile workflow