Skip to content
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

TypeError: Cannot read properties of undefined (reading 'body') #58

Closed
mwkcoding opened this issue Oct 25, 2024 · 2 comments
Closed

TypeError: Cannot read properties of undefined (reading 'body') #58

mwkcoding opened this issue Oct 25, 2024 · 2 comments

Comments

@mwkcoding
Copy link

I'm trying to use the lock action headless to enable locks to make sure an environment can only be used for one PR at a time.

But when I try to lock the environment I get this error:

/home/runner/work/_actions/github/lock/v2/src/main.js:63
    const body = context.payload.comment.body.trim()
^
TypeError: Cannot read properties of undefined (reading 'body')
    at run (/home/runner/work/_actions/github/lock/v2/src/main.js:63:1)
    at /home/runner/work/_actions/github/lock/v2/src/main.js:289:1
    at /home/runner/work/_actions/github/lock/v2/dist/index.js:326[82]([REPO_URL]/actions/runs/11520936978/job/32073423092#step:5:83):3
    at Object.<anonymous> (/home/runner/work/_actions/github/lock/v2/dist/index.js:32685:12)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49

The step I am trying to run that fails

...
- name: Lock environment
  uses: github/lock@v2
  id: lock-environment
  if: steps.lock-check.outputs.locked == 'false'
  with:
    environment: ${{ needs.get-slot-from-label.outputs.slot }}
    github_token: ${{ secrets.GITHUB_TOKEN }}
...
@mwkcoding
Copy link
Author

It looks like it assumes there's a body from an issue comment to read. This is not the case when using the action purely headless.

@mwkcoding
Copy link
Author

I was missing the "mode" input. Works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant