Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error: Unhandled error: SyntaxError: Unexpected token '{' #401

Closed
@denys-parloa

Description

@denys-parloa

Hello!

I use this workflow element (To Reproduce section) to display the terraform plan, the variable ${{ steps.show-plan.outputs.stdout }} contains a string with special characters plus json elements.

How to avoid this issue? Probably I need to encode the string somehow ..

Tried including result-encoding: string but same result.
By the way, about a month ago this workflow worked fine.

Describe the bug

SyntaxError: Unexpected token '{'
    at new AsyncFunction (<anonymous>)
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16)
    at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15236:26)
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15217:1
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15268:3
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15[271](https://github.com/parloa/parloa-infra/actions/runs/5422135137/jobs/9858405881#step:12:272):12)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
Error: Unhandled error: SyntaxError: Unexpected token '{'
A clear and concise description of what the bug is.

To Reproduce

   - name: Update Pull Request
      uses: actions/github-script@v6
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        result-encoding: string
        script: |
          const output = `
          <details><summary>Show Plan</summary>
          \`\`\`\n
          ${{ steps.show-workspace.outputs.stdout }}
          ${{ steps.show-var-file.outputs.stdout }}
          ${{ steps.show-plan.outputs.stdout }}
          \`\`\`
          </details>
          `;
          
          github.rest.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: output
          })

Desktop (please complete the following information):

  • GitHub Action

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions