REST API: Query with date fields isn't working anymore?

Hi!

I’m working with the sdk for an indivdiual bot. I have requested some information and it was working great for some time:

const result = await api.get('im.list.everyone', {
    fields: {lastMessage: 1},
    query: {_updatedAt: {$gt: oldTreshold}}
});

This code has given me all of the private rooms updated since a specific time. Now this code isn’t working anymore. If I forgo the query parameter the call is still working. But with the query the result is always empty. Even if the value of oldTreshold is zero. What has changed? Is this a bug? Can somebody confirm this weird behavior?

SDK Version: 0.2.9
Server Version: 0.69.2

Hi Bekay

I found some recent weirdness with API queries too. Detailed here and effected by this PR.

I can’t promise that’s your issue, but it’s a place to start.

Adding @marcos.defendi here.

Hi @bekay, I tested it here and could not simulate its error. As the @tim.kinnane said above, there was a bug that was fixed with the PR shown by him. I also tried to filter with your query directly in mongodb, and did not return any records, what is the content of your oldTreshold variable? Is it a Date instance?

The oldTreshold is the valueOf a Date instance. But I have tried it with an Date too. But if you even get no results querying the database directly, what is wrong with the query? I see no errors in it…

Okay, the problem still persists. It is annoying and a real pain for us. The only idea I have is that the query parameter for any kind of date query has to be a Date instance. But at that point the _updatedAt query param is a string, because it was read from the get parameters of the API request. Should I file a bug report?

Did it, because I could reproduce the fail in a case: https://github.com/RocketChat/Rocket.Chat/issues/12660

The issue was closed with some incoherent rambling. I am really feeling mocked here by the Rocket.Chat team… I have worked 5 to 6 hours already on this problem. Can please somebody reopen this issue or help me to track this down.

Hi @bekay, I answered you on the issue thread. Thanks.

I’ve already seen it. Thank you very much for your effort!

1 Like