Clockify trigger error?

Hi all,

I’ve been testing the Clockify trigger but I can’t get it to work unfortunately.
When adding a polling time, doesn’t matter if it’s days, minutes or hours, I am getting the following error:

ERROR: Clockify Error: [undefined] getTimeEntries.end: You entered invalid value for field : [end]. Values that represent [end] can be null and can be empty. .Please make sure that the [end] date is not greater than 9999-12-31 and not less than 0001-01-01. Ensure that the [end] date is in following format: "yyyy-MM-ddThh:mm:ssZ" Example: 2018-11-29T13:00:46Z.


Error: Clockify Error: [undefined] getTimeEntries.end: You entered invalid value for field : [end]. Values that represent [end] can be null and can be empty. .Please make sure that the [end] date is not greater than 9999-12-31 and not less than 0001-01-01. Ensure that the [end] date is in following format: "yyyy-MM-ddThh:mm:ssZ" Example: 2018-11-29T13:00:46Z. 
    at Object.clockifyApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Clockify/GenericFunctions.js:28:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Also when removing the polling interval from n8n I am getting the following error:

ERROR: Cannot read property '0' of undefined
TypeError: Cannot read property '0' of undefined
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:371:79
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Strange thing is when I re-add the polling time it works and I can see my Clockify times but when I click save I am getting the error above so I cannot use it. Anyone knows how to fix this?

Here’s the Clockify node:

{
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "workspaceId": "5e9d94231715b26d040adc9b"
      },
      "name": "Clockify Trigger",
      "type": "n8n-nodes-base.clockifyTrigger",
      "typeVersion": 1,
      "position": [
        390,
        300
      ],
      "credentials": {
        "clockifyApi": "Clockify"
      }
    }
  ],
  "connections": {}
}

Thanks,

Patrick

I tried to debug it now but sadly do not understand what is going on. Sometimes it works perfectly for me other times not. For me it does however not look like an error in n8n more like that Clockify does something strange. Here an exmple:

Query String which gets send:

{
  "start": "2020-04-21T14:17:25Z",
  "end": "2020-04-21T14:19:96Z",
  "hydrated": true,
  "in-progress": false
}

The resulting error response from Clockify:

getTimeEntries.end: You entered invalid value for field : [end]. Values that represent [end] can be null and can be empty. .Please make sure that the [end] date is not greater than 9999-12-31 and not less than 0001-01-01. Ensure that the [end] date is in following format: "yyyy-MM-ddThh:mm:ssZ" Example: 2018-11-29T13:00:46Z. 

This request a few minutes later then works totally fine?!?!?

{
  "start": "2020-04-21T14:24:45Z",
  "end": "2020-04-21T14:25:21Z",
  "hydrated": true,
  "in-progress": false
}

As you can see does “end” get set toa valid value and a correct format both times. So really do not know right now what can be done here.

@RicardoE105 can you please check with the Clockify-Support if they have an idea what could be going wrong. Thanks!

that’s exactly the problem, sometimes it works fine other times I’m getting all kinds of errors from Clockify. indeed a Clockify error rather than a n8n error. Thanks for clarifying!

@patrick @jan already emailed the support. Let’s see what they come up with.

1 Like

@patrick the issue is fixed. @jan will let you know when is released.

Can you share with us what this issue was?

Yes, of course.

The end date was being formatted incorrectly.

qs.end = moment().tz(workflowTimezone).format('YYYY-MM-DDTHH:mm:SS') + 'Z';

as you can see there the SS was being used to represent seconds but it is actually used for fractional seconds. Fractional second range from 0 to 99 meaning every time the fractional seconds were below 59 it worked and above that it failed because it’s not a valid value for the API.

I just changed the SS to ss and now it always returns seconds.

More details about that here https://momentjs.com/docs/#/displaying/format/

2 Likes

Thanks a lot @RicardoE105!

My example above that failed was even 2020-04-21T14:19:96Z.
So with 96 seconds :man_facepalming:

Fix got released with [email protected]

Thanks for fixing @RicardoE105!

1 Like

@RicardoE105 hmm, I’ve just noticed that everytime I execute the Clockify trigger manually, the results are empty, even though I added some records in Clockify. When setting the polling mode to for example every minute it doesn’t do anything and won’t log anything in the Executions tab. Do you have the same behaviour?