Skip to content

Cannot read property 'id' of undefined - in on: workflow_dispatch #7

@mkarnicki

Description

@mkarnicki

It seems that workflow_dispatch event is not correctly handled, full stack trace below.

Error:

TypeError: Cannot read property 'id' of undefined

I believe this line is the source of the problem. It is not a pull request, so it tries to reach for payload.head_commit.id

    const commitId = isPullRequest ? payload.pull_request.head.sha : payload.head_commit.id;

Stack trace:

Run webfactory/[email protected]
  with:
    application: redacted
  env:
    SERVICE_ROLE_ARN: ***
    AWS_DEFAULT_REGION: eu-west-1
    AWS_REGION: eu-west-1
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
(node:1872) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at /home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:194:90
    at Object.2932 (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:203:3)
    at __webpack_require__ (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:50113:43)
    at /home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:50130:18
    at Object.<anonymous> (/home/runner/work/_actions/webfactory/create-aws-codedeploy-deployment/v0.2.2/dist/index.js:50131:12)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
(node:1872) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1872) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Have a great day and thanks for this awesome custom GH Action. It works well otherwise (with non-workflow_dispatch events).

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