abhisheknaiidu / todoist-readme

🚧 Updates README with Todoist Stats of a user
https://github.com/marketplace/actions/todoist-readme
Creative Commons Zero v1.0 Universal
152 stars 55 forks source link

PREMIUM variable type issue #13

Closed jaejin1 closed 3 years ago

jaejin1 commented 3 years ago

Hi, I am a non-preminum user in todoist. So, I set up the workflow yaml file as follows according to the settings you gave me.

name: Todoist Readme

on:
  workflow_dispatch:
  schedule:
    # Runs every minute 
    - cron: '* * * * *'

jobs:
  update-readme:
    name: Update todoist stats
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: abhisheknaiidu/todoist-readme@master
        with:
          TODOIST_API_KEY: ${{ secrets.TODOIST_API_KEY }}

However, when I checked the github action log, the following error occurred. Run abhisheknaiidu/todoist-readme@master with: TODOIST_API_KEY: *** USERNAME: jaejin1 PREMIUM: false (node:2894) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'total_completed' of undefined at updateReadme (/home/runner/work/_actions/abhisheknaiidu/todoist-readme/master/dist/index.js:486:57) at main (/home/runner/work/_actions/abhisheknaiidu/todoist-readme/master/dist/index.js:465:11) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async /home/runner/work/_actions/abhisheknaiidu/todoist-readme/master/dist/index.js:587:5 (node:2894) 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: 2) (node:2894) [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.

When checking the code, it seems that the PREMIUM variable is read as a string type from the yaml file. The line of code is https://github.com/abhisheknaiidu/todoist-readme/blob/master/dist/index.js#L485.

So I tested it by giving the PREMIUM value "", and it succeeded.

with:
     TODOIST_API_KEY: ${{ secrets.TODOIST_API_KEY }}
     PREMIUM: ""

Create and share a PR with the issue.

jaejin1 commented 3 years ago

https://github.com/abhisheknaiidu/todoist-readme/pull/14

abhisheknaiidu commented 3 years ago

@jaejin1 Thanks for raising this issue