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
Currently, it's really difficult to determine where an error occurred in a user's script input, because of how it's evaluated.
One option for improving this might be two wrap the user script in a string for creating the async function, and then writing that to a file and executing it.
Reacted by Juan Julián Merelo Guervós, Judson James, sandwich, haruna and Rohit Gohri
I'm closing this—the line/column for the anonymous function in stack traces is actually accurate.
@jcansdale To your point about source maps, they wouldn't help in this case, because the user scripts themselves aren't transpiled, so source maps wouldn't add any clarity around errors in the eval'd functions.
I'd expect any escaping needed to be done automatically. Seems weird for context data to be evaluated like script code. Are there use cases for writing script logic that way?
The issue is that ${{}} interpolation is performed by Actions before the script content is sent to this particular action. When the github-script actions receives the script, the interpolation has already been completed and I have no way of knowing which parts of it may have been interpolated.
This is a limitation of implementing this action in user-space, essentially. It's not a design choice.
So if your content is hello"world and your workflow has foo: "${{ content }}", the script will be received as foo: "hello"world".
${{}} uses very literal template interpolation, because it is used in many different contexts, including many outside of JavaScript (shell scripts, other programming languages, plain workflow strings, etc). As far as the Actions runtime itself is concerned, the script param is a plain string, it has zero knowledge that it should escape interpolated values as if they're being inserted into a JavaScript expression.
Activity
jcansdale commentedon Jan 12, 2020
I wonder if source-maps could be used here? 🤔
https://survivejs.com/webpack/building/source-maps/
jclem commentedon Feb 28, 2020
I'm closing this—the line/column for the
anonymousfunction in stack traces is actually accurate.@jcansdale To your point about source maps, they wouldn't help in this case, because the user scripts themselves aren't transpiled, so source maps wouldn't add any clarity around errors in the eval'd functions.
afwn90cj93201nixr2e1re commentedon Apr 12, 2020
@jclem

SyntaxError: Invalid or unexpected token
same with single quotes. So, what's the problem?
afwn90cj93201nixr2e1re commentedon Apr 12, 2020
afwn90cj93201nixr2e1re commentedon Apr 12, 2020
https://github.com/marketplace/actions/create-or-update-comment
btw this extension works well.
adbl commentedon Aug 20, 2021
@afwn90cj93201nixr2e1re did you figure out what this problem is about?
afwn90cj93201nixr2e1re commentedon Aug 20, 2021
No, as you can see above, I just used another extension
jclem commentedon Aug 23, 2021
What's the exact content of
env.comment? Double quotes, for example, would cause a syntax error.adbl commentedon Aug 23, 2021
I'd expect any escaping needed to be done automatically. Seems weird for context data to be evaluated like script code. Are there use cases for writing script logic that way?
jclem commentedon Aug 23, 2021
The issue is that ${{}} interpolation is performed by Actions before the script content is sent to this particular action. When the github-script actions receives the script, the interpolation has already been completed and I have no way of knowing which parts of it may have been interpolated.
This is a limitation of implementing this action in user-space, essentially. It's not a design choice.
So if your content is
hello"worldand your workflow hasfoo: "${{ content }}", the script will be received asfoo: "hello"world".${{}} uses very literal template interpolation, because it is used in many different contexts, including many outside of JavaScript (shell scripts, other programming languages, plain workflow strings, etc). As far as the Actions runtime itself is concerned, the
scriptparam is a plain string, it has zero knowledge that it should escape interpolated values as if they're being inserted into a JavaScript expression.TWiStErRob commentedon Jun 4, 2022
Anyone fighting with this in the future, https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging or the equivalent "Enable debug logging" at https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs helps to see what the end result of the substitutions was.