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

[BUDI-7447] Finish and test automation for cron trigger timestamp binding is incorrect type (string instead of number) #11663

Closed
1 task done
melohagan opened this issue Sep 5, 2023 · 2 comments
Labels
bb-automations Budibase Automations related work bug Something isn't working env - production Bug found in production firestorm Data/Infra/Revenue Team Low priority Created by Linear-GitHub Sync

Comments

@melohagan
Copy link
Collaborator

melohagan commented Sep 5, 2023

Checklist

  • I have searched budibase discussions and github issues to check if my issue already exists

Hosting

  • Self
    • Method: docker compose
    • Budibase Version: 2.9.36

Describe the bug
I initially thought the filtering was broken, but I believe it's specifically that the test input for the timestamp is being ignored, and the cron job is using the actual current timestamp.

To Reproduce
Steps to reproduce the behavior:

  1. Add an automation with cron trigger: 0 * * * *
  2. Add a step: Query Rows for the 'Employees' table
  3. Define filters: Start Date More than or equal to Binding:
return new Date($("trigger.timestamp") - (2 * 60 * 60 * 1000))
  1. Finish and test automation
  2. Enter a timestamp of a past date that would return values (e.g. 2014)
  3. See that no values are returned.
  4. Go to the Employees table, and set some of the start dates into the future (e.g. 2024)
  5. Test the automation and see that those rows will be returned

Expected behavior
When running an automation test, the input timestamp should be used and not the current timestamp.

Screenshots

This should return all rows

But only the checked rows are returned by the query rows

Additional context
As this is filtering on the timestamp number type field, it may be related to this bug: #11418

From SyncLinear.com | BUDI-7447

@melohagan melohagan added bug Something isn't working bb-automations Budibase Automations related work env - production Bug found in production labels Sep 5, 2023
@melohagan melohagan changed the title Finish and test automation for cron trigger ignores test timestamp when filtering [BUDI-7447] Finish and test automation for cron trigger ignores test timestamp when filtering Sep 5, 2023
@melohagan melohagan added firestorm Data/Infra/Revenue Team Low priority Created by Linear-GitHub Sync labels Sep 5, 2023
@melohagan
Copy link
Collaborator Author

melohagan commented Nov 2, 2023

Re-opening as this is still a problem. It's not specific to filtering, the issue is that when testing the timestamp is of type string and must be cast to a number, however in production it correctly has the number type.

The fix would be to ensure timestamp is of type number when testing.

const currentDate = new Date($("trigger.timestamp"));

This will work in production, but not in test

const currentDate = new Date(Number($("trigger.timestamp")));

This will work in both test and production, but shouldn't be necessary


Screenshot 2023-11-02 at 10 56 41

Screenshot 2023-11-02 at 10 56 50

@melohagan melohagan reopened this Nov 2, 2023
@melohagan melohagan changed the title [BUDI-7447] Finish and test automation for cron trigger ignores test timestamp when filtering [BUDI-7447] Finish and test automation for cron trigger timestamp binding is incorrect type (string instead of number) Nov 2, 2023
@melohagan melohagan added Medium priority Created by Linear-GitHub Sync Low priority Created by Linear-GitHub Sync and removed Low priority Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync labels Nov 2, 2023
@melohagan
Copy link
Collaborator Author

To add to this one, it does appear to not work in production either.

For example this works:

const triggerTimestamp = $("trigger.timestamp")
const currentDate = new Date(1700211176994);

but this does not:

const triggerTimestamp = $("trigger.timestamp")
const currentDate = new Date(Number(triggerTimestamp));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bb-automations Budibase Automations related work bug Something isn't working env - production Bug found in production firestorm Data/Infra/Revenue Team Low priority Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

2 participants