TiagoDanin / Add-License-Bot

Generate LICENSE file from package.json
https://tiagodanin.github.io/Add-License-Bot/
MIT License
6 stars 2 forks source link

Public app doesn't seem to work, tests failing #114

Closed jethror1 closed 3 years ago

jethror1 commented 3 years ago

I tried linking the public app to a test public repo I made to check out the license bot as it would be great to use, it doesn't seem to do anything to the main / on opening a PR etc. (not sure when it is meant to run as it isn't in the readme).

I then grabbed the repo to try run it locally, and on adding to the repo I get the following error (full traceback at bottom):

ERROR (event): Cannot read property 'repos' of undefined
    TypeError: Cannot read property 'repos' of undefined
        at checkFiles (/home/jethro/Downloads/Add-License-Bot-master/index.js:53:34)
        at /home/jethro/Downloads/Add-License-Bot-master/index.js:119:10
        at /home/jethro/Downloads/Add-License-Bot-master/node_modules/@octokit/webhooks/dist-node/index.js:115:14
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async Promise.all (index 0)

Running tests locally gives the following warnings / errors:

  index.js:85:33
  ⚠   29:6   Prefer await to then()/catch()/finally().                                 promise/prefer-await-to-then
  ⚠   42:8   Prefer await to then()/catch()/finally().                                 promise/prefer-await-to-then
  ⚠   46:6   Prefer await to then()/catch()/finally().                                 promise/prefer-await-to-then
  ⚠   53:21  Unexpected await inside a loop.                                           no-await-in-loop
  ⚠   61:47  Prefer await to then()/catch()/finally().                                 promise/prefer-await-to-then
  ⚠  101:6   Prefer await to then()/catch()/finally().                                 promise/prefer-await-to-then
  ⚠  119:4   Unexpected await inside a loop.                                           no-await-in-loop
  ✖   85:33  unicorn/no-fn-reference-in-iterator rule is disabled but never reported.  eslint-comments/no-unused-disable
  ✖   86:41  Do not pass function licenseType directly to .find(…).                    unicorn/no-array-callback-reference

  7 warnings
  2 errors
npm ERR! Test failed.  See above for more details.

Is this an issue with the bot or has GitHub changed and caused this to break? Happy to help fix it if you can help out as it would be super useful for automatically adding licences on PRs to our current repos

Thanks!



Full traceback:

INFO (probot): Yay, the app was loaded!
"integration_installation_repositories" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)
INFO (server): Running Probot v11.3.0 (Node.js: v14.17.2)
INFO (server): Forwarding https://smee.io/bkDqy4wIZtMi99U to http://localhost:3000/
INFO (server): Listening on http://localhost:3000
INFO (server): Connected
INFO (http): GET /probot 200 - 89ms
INFO (http): GET /primer.css 304 - 7ms
INFO (http): GET /robot.svg 304 - 4ms
INFO (http): GET /probot-head.png 200 - 9ms
INFO (probot): Analyzed
ERROR (event): Cannot read property 'repos' of undefined
    TypeError: Cannot read property 'repos' of undefined
        at checkFiles (/home/jethro/Downloads/Add-License-Bot-master/index.js:53:34)
        at /home/jethro/Downloads/Add-License-Bot-master/index.js:119:10
        at /home/jethro/Downloads/Add-License-Bot-master/node_modules/@octokit/webhooks/dist-node/index.js:115:14
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async Promise.all (index 0)
event: {
    id: "d46941d0-dfd8-11eb-9091-b72179a6999d"
    name: "installation_repositories"
    payload: {
      "action": "added",
      "installation": {
        "id": 18150662,
        "account": {
          "login": "jethror1",
          "id": 45037268,
          "node_id": "MDQ6VXNlcjQ1MDM3MjY4",
          "avatar_url": "https://avatars.githubusercontent.com/u/45037268?v=4",
          "gravatar_id": "",
          "url": "https://api.github.com/users/jethror1",
          "html_url": "https://github.com/jethror1",
          "followers_url": "https://api.github.com/users/jethror1/followers",
          "following_url": "https://api.github.com/users/jethror1/following{/other_user}",
          "gists_url": "https://api.github.com/users/jethror1/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/jethror1/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/jethror1/subscriptions",
          "organizations_url": "https://api.github.com/users/jethror1/orgs",
          "repos_url": "https://api.github.com/users/jethror1/repos",
          "events_url": "https://api.github.com/users/jethror1/events{/privacy}",
          "received_events_url": "https://api.github.com/users/jethror1/received_events",
          "type": "User",
          "site_admin": false
        },
        "repository_selection": "selected",
        "access_tokens_url": "https://api.github.com/app/installations/18150662/access_tokens",
        "repositories_url": "https://api.github.com/installation/repositories",
        "html_url": "https://github.com/settings/installations/18150662",
        "app_id": 125554,
        "app_slug": "add-license-jr",
        "target_id": 45037268,
        "target_type": "User",
        "permissions": {
          "contents": "write",
          "metadata": "read"
        },
        "events": [
          "push"
        ],
        "created_at": "2021-07-08T11:36:35.000+01:00",
        "updated_at": "2021-07-08T11:36:36.000+01:00",
        "single_file_name": null,
        "has_multiple_single_files": false,
        "single_file_paths": [],
        "suspended_by": null,
        "suspended_at": null
      },
      "repository_selection": "selected",
      "repositories_added": [
        {
          "id": 384089422,
          "node_id": "MDEwOlJlcG9zaXRvcnkzODQwODk0MjI=",
          "name": "test-licence-bot",
          "full_name": "jethror1/test-licence-bot",
          "private": false
        }
      ],
      "repositories_removed": [],
      "requester": null,
      "sender": {
        "login": "jethror1",
        "id": 45037268,
        "node_id": "MDQ6VXNlcjQ1MDM3MjY4",
        "avatar_url": "https://avatars.githubusercontent.com/u/45037268?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/jethror1",
        "html_url": "https://github.com/jethror1",
        "followers_url": "https://api.github.com/users/jethror1/followers",
        "following_url": "https://api.github.com/users/jethror1/following{/other_user}",
        "gists_url": "https://api.github.com/users/jethror1/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/jethror1/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/jethror1/subscriptions",
        "organizations_url": "https://api.github.com/users/jethror1/orgs",
        "repos_url": "https://api.github.com/users/jethror1/repos",
        "events_url": "https://api.github.com/users/jethror1/events{/privacy}",
        "received_events_url": "https://api.github.com/users/jethror1/received_events",
        "type": "User",
        "site_admin": false
      }
    }
}
INFO (http): POST / 500 - 26ms
    err: {
      "type": "Error",
      "message": "failed with status code 500",
      "stack":
          Error: failed with status code 500
              at ServerResponse.onResFinished (/home/jethro/Downloads/Add-License-Bot-master/node_modules/pino-http/logger.js:73:38)
              at ServerResponse.emit (events.js:387:35)
              at ServerResponse.emit (domain.js:470:12)
              at onFinish (_http_outgoing.js:792:10)
              at callback (internal/streams/writable.js:513:21)
              at afterWrite (internal/streams/writable.js:466:5)
              at afterWriteTick (internal/streams/writable.js:453:10)
              at processTicksAndRejections (internal/process/task_queues.js:81:21)
    }
ERROR (server): Internal Server Error
    Error: Internal Server Error
        at Request.callback (/home/jethro/Downloads/Add-License-Bot-master/node_modules/superagent/lib/node/index.js:883:15)
        at IncomingMessage.<anonymous> (/home/jethro/Downloads/Add-License-Bot-master/node_modules/superagent/lib/node/index.js:1126:20)
        at IncomingMessage.emit (events.js:387:35)
        at IncomingMessage.emit (domain.js:470:12)
        at endReadableNT (internal/streams/readable.js:1317:12)
        at processTicksAndRejections (internal/process/task_queues.js:82:21)
status: 500
INFO (probot): Analyzed
ERROR (event): Cannot read property 'repos' of undefined
    TypeError: Cannot read property 'repos' of undefined
        at checkFiles (/home/jethro/Downloads/Add-License-Bot-master/index.js:53:34)
        at /home/jethro/Downloads/Add-License-Bot-master/index.js:127:10
        at /home/jethro/Downloads/Add-License-Bot-master/node_modules/@octokit/webhooks/dist-node/index.js:115:14
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async Promise.all (index 0)
event: {
    id: "04f81290-dfd9-11eb-98d1-aebc3a959b10"
    name: "push"
    payload: {
      "ref": "refs/heads/test-branch",
      "before": "0000000000000000000000000000000000000000",
      "after": "5184075f12c7e54e14d958ac9aa42bb8b81d1590",
      "repository": {
        "id": 384089422,
        "node_id": "MDEwOlJlcG9zaXRvcnkzODQwODk0MjI=",
        "name": "test-licence-bot",
        "full_name": "jethror1/test-licence-bot",
        "private": false,
        "owner": {
          "name": "jethror1",
          "email": "45037268+jethror1@users.noreply.github.com",
          "login": "jethror1",
          "id": 45037268,
          "node_id": "MDQ6VXNlcjQ1MDM3MjY4",
          "avatar_url": "https://avatars.githubusercontent.com/u/45037268?v=4",
          "gravatar_id": "",
          "url": "https://api.github.com/users/jethror1",
          "html_url": "https://github.com/jethror1",
          "followers_url": "https://api.github.com/users/jethror1/followers",
          "following_url": "https://api.github.com/users/jethror1/following{/other_user}",
          "gists_url": "https://api.github.com/users/jethror1/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/jethror1/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/jethror1/subscriptions",
          "organizations_url": "https://api.github.com/users/jethror1/orgs",
          "repos_url": "https://api.github.com/users/jethror1/repos",
          "events_url": "https://api.github.com/users/jethror1/events{/privacy}",
          "received_events_url": "https://api.github.com/users/jethror1/received_events",
          "type": "User",
          "site_admin": false
        },
        "html_url": "https://github.com/jethror1/test-licence-bot",
        "description": null,
        "fork": false,
        "url": "https://github.com/jethror1/test-licence-bot",
        "forks_url": "https://api.github.com/repos/jethror1/test-licence-bot/forks",
        "keys_url": "https://api.github.com/repos/jethror1/test-licence-bot/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/jethror1/test-licence-bot/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/jethror1/test-licence-bot/teams",
        "hooks_url": "https://api.github.com/repos/jethror1/test-licence-bot/hooks",
        "issue_events_url": "https://api.github.com/repos/jethror1/test-licence-bot/issues/events{/number}",
        "events_url": "https://api.github.com/repos/jethror1/test-licence-bot/events",
        "assignees_url": "https://api.github.com/repos/jethror1/test-licence-bot/assignees{/user}",
        "branches_url": "https://api.github.com/repos/jethror1/test-licence-bot/branches{/branch}",
        "tags_url": "https://api.github.com/repos/jethror1/test-licence-bot/tags",
        "blobs_url": "https://api.github.com/repos/jethror1/test-licence-bot/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/jethror1/test-licence-bot/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/jethror1/test-licence-bot/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/jethror1/test-licence-bot/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/jethror1/test-licence-bot/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/jethror1/test-licence-bot/languages",
        "stargazers_url": "https://api.github.com/repos/jethror1/test-licence-bot/stargazers",
        "contributors_url": "https://api.github.com/repos/jethror1/test-licence-bot/contributors",
        "subscribers_url": "https://api.github.com/repos/jethror1/test-licence-bot/subscribers",
        "subscription_url": "https://api.github.com/repos/jethror1/test-licence-bot/subscription",
        "commits_url": "https://api.github.com/repos/jethror1/test-licence-bot/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/jethror1/test-licence-bot/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/jethror1/test-licence-bot/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/jethror1/test-licence-bot/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/jethror1/test-licence-bot/contents/{+path}",
        "compare_url": "https://api.github.com/repos/jethror1/test-licence-bot/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/jethror1/test-licence-bot/merges",
        "archive_url": "https://api.github.com/repos/jethror1/test-licence-bot/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/jethror1/test-licence-bot/downloads",
        "issues_url": "https://api.github.com/repos/jethror1/test-licence-bot/issues{/number}",
        "pulls_url": "https://api.github.com/repos/jethror1/test-licence-bot/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/jethror1/test-licence-bot/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/jethror1/test-licence-bot/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/jethror1/test-licence-bot/labels{/name}",
        "releases_url": "https://api.github.com/repos/jethror1/test-licence-bot/releases{/id}",
        "deployments_url": "https://api.github.com/repos/jethror1/test-licence-bot/deployments",
        "created_at": 1625740715,
        "updated_at": "2021-07-08T10:39:38Z",
        "pushed_at": 1625740874,
        "git_url": "git://github.com/jethror1/test-licence-bot.git",
        "ssh_url": "git@github.com:jethror1/test-licence-bot.git",
        "clone_url": "https://github.com/jethror1/test-licence-bot.git",
        "svn_url": "https://github.com/jethror1/test-licence-bot",
        "homepage": null,
        "size": 0,
        "stargazers_count": 0,
        "watchers_count": 0,
        "language": null,
        "has_issues": true,
        "has_projects": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "forks_count": 0,
        "mirror_url": null,
        "archived": false,
        "disabled": false,
        "open_issues_count": 0,
        "license": null,
        "forks": 0,
        "open_issues": 0,
        "watchers": 0,
        "default_branch": "main",
        "stargazers": 0,
        "master_branch": "main"
      },
      "pusher": {
        "name": "jethror1",
        "email": "45037268+jethror1@users.noreply.github.com"
      },
      "sender": {
        "login": "jethror1",
        "id": 45037268,
        "node_id": "MDQ6VXNlcjQ1MDM3MjY4",
        "avatar_url": "https://avatars.githubusercontent.com/u/45037268?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/jethror1",
        "html_url": "https://github.com/jethror1",
        "followers_url": "https://api.github.com/users/jethror1/followers",
        "following_url": "https://api.github.com/users/jethror1/following{/other_user}",
        "gists_url": "https://api.github.com/users/jethror1/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/jethror1/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/jethror1/subscriptions",
        "organizations_url": "https://api.github.com/users/jethror1/orgs",
        "repos_url": "https://api.github.com/users/jethror1/repos",
        "events_url": "https://api.github.com/users/jethror1/events{/privacy}",
        "received_events_url": "https://api.github.com/users/jethror1/received_events",
        "type": "User",
        "site_admin": false
      },
      "installation": {
        "id": 18150662,
        "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTgxNTA2NjI="
      },
      "created": true,
      "deleted": false,
      "forced": false,
      "base_ref": null,
      "compare": "https://github.com/jethror1/test-licence-bot/commit/5184075f12c7",
      "commits": [
        {
          "id": "5184075f12c7e54e14d958ac9aa42bb8b81d1590",
          "tree_id": "daa4d15d31fd0c3cd23c7f136f74fdcf7763a95e",
          "distinct": true,
          "message": "Create file",
          "timestamp": "2021-07-08T11:41:14+01:00",
          "url": "https://github.com/jethror1/test-licence-bot/commit/5184075f12c7e54e14d958ac9aa42bb8b81d1590",
          "author": {
            "name": "jethror1",
            "email": "45037268+jethror1@users.noreply.github.com",
            "username": "jethror1"
          },
          "committer": {
            "name": "GitHub",
            "email": "noreply@github.com",
            "username": "web-flow"
          },
          "added": [
            "file"
          ],
          "removed": [],
          "modified": []
        }
      ],
      "head_commit": {
        "id": "5184075f12c7e54e14d958ac9aa42bb8b81d1590",
        "tree_id": "daa4d15d31fd0c3cd23c7f136f74fdcf7763a95e",
        "distinct": true,
        "message": "Create file",
        "timestamp": "2021-07-08T11:41:14+01:00",
        "url": "https://github.com/jethror1/test-licence-bot/commit/5184075f12c7e54e14d958ac9aa42bb8b81d1590",
        "author": {
          "name": "jethror1",
          "email": "45037268+jethror1@users.noreply.github.com",
          "username": "jethror1"
        },
        "committer": {
          "name": "GitHub",
          "email": "noreply@github.com",
          "username": "web-flow"
        },
        "added": [
          "file"
        ],
        "removed": [],
        "modified": []
      }
    }
}
INFO (http): POST / 500 - 32ms
    err: {
      "type": "Error",
      "message": "failed with status code 500",
      "stack":
          Error: failed with status code 500
              at ServerResponse.onResFinished (/home/jethro/Downloads/Add-License-Bot-master/node_modules/pino-http/logger.js:73:38)
              at ServerResponse.emit (events.js:387:35)
              at ServerResponse.emit (domain.js:470:12)
              at onFinish (_http_outgoing.js:792:10)
              at callback (internal/streams/writable.js:513:21)
              at afterWrite (internal/streams/writable.js:466:5)
              at afterWriteTick (internal/streams/writable.js:453:10)
              at processTicksAndRejections (internal/process/task_queues.js:81:21)
    }
ERROR (server): Internal Server Error
    Error: Internal Server Error
        at Request.callback (/home/jethro/Downloads/Add-License-Bot-master/node_modules/superagent/lib/node/index.js:883:15)
        at IncomingMessage.<anonymous> (/home/jethro/Downloads/Add-License-Bot-master/node_modules/superagent/lib/node/index.js:1126:20)
        at IncomingMessage.emit (events.js:387:35)
        at IncomingMessage.emit (domain.js:470:12)
        at endReadableNT (internal/streams/readable.js:1317:12)
        at processTicksAndRejections (internal/process/task_queues.js:82:21)
status: 500
jethror1 commented 3 years ago

Realised it needs package.json adding which test repo didn't have :facepalm: