Skip to content

Make debugging easier #1

Closed
Closed

Description

@jclem

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.

Activity

  1. jcansdale commented on Jan 12, 2020

    @jcansdale
    Contributor

    I wonder if source-maps could be used here? 🤔
    https://survivejs.com/webpack/building/source-maps/

  2. jclem commented on Feb 28, 2020

    @jclem
    ContributorAuthor

    I'm closing this—the line/column for the anonymous function in stack traces is actually accurate.

    Screen Shot 2020-02-28 at 10 05 54 AM

    @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.

  3. afwn90cj93201nixr2e1re commented on Apr 12, 2020

    @afwn90cj93201nixr2e1re

    @jclem
    изображение

    SyntaxError: Invalid or unexpected token

    same with single quotes. So, what's the problem?

  4. afwn90cj93201nixr2e1re commented on Apr 12, 2020

    @afwn90cj93201nixr2e1re
    on:
        issue_comment:
            types: [created]
    
                - name: Prepare comment file
                  run: |
                    echo -e "[${{github.event.comment.user.login}}](${{github.event.comment.user.url}}) tryna get copy for ${{env.IP_ADDR}}\n\n\nYou can try to get artifact from: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}" > git_comment.txt
    
                - name: Create comment context1
                  if: always()
                  shell: bash
                  run: |
                    REPORT="$(cat git_comment.txt)"
                    REPORT="${REPORT//'%'/'%25'}"
                    REPORT="${REPORT//$'\n'/'%0A'}"
                    REPORT="${REPORT//$'\r'/'%0D'}"
                    echo "::set-env name=comment::$REPORT"  
    
                - uses: actions/github-script@0.9.0
                  if: always()
                  with:
                    github-token: ${{secrets.GITHUB_TOKEN}}
                    script: |
                        github.issues.createComment({
                            issue_number: ${{ github.event.issue.number }},
                            owner: context.repo.owner,
                            repo: context.repo.repo,
                            body: "${{ env.comment }}"
                        })
    
  5. afwn90cj93201nixr2e1re commented on Apr 12, 2020

    @afwn90cj93201nixr2e1re
  6. adbl commented on Aug 20, 2021

    @adbl

    @afwn90cj93201nixr2e1re did you figure out what this problem is about?

  7. afwn90cj93201nixr2e1re commented on Aug 20, 2021

    @afwn90cj93201nixr2e1re

    No, as you can see above, I just used another extension

  8. jclem commented on Aug 23, 2021

    @jclem
    ContributorAuthor

    What's the exact content of env.comment? Double quotes, for example, would cause a syntax error.

  9. adbl commented on Aug 23, 2021

    @adbl

    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?

  10. jclem commented on Aug 23, 2021

    @jclem
    ContributorAuthor

    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.

  11. TWiStErRob commented on Jun 4, 2022

    @TWiStErRob

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ Proxy