cognitedata/cognite-sdk-js

Date conversion is too intrusive

Closed this issue · 5 comments

The SDK will traverse the response body and convert any field that matches a certain set of names to javascript Date objects (https://github.com/cognitedata/cognite-sdk-js/blob/b95c4e769920526f9f20d5e1e8e5070b5b34f7e4/src/utils.ts#L105L120).

This is not necessarily valid to do in the general case.

For example, say I have a RAW table which contains a column named timestamp, which stores seconds since unix epoch. The Date constructor takes a value in milliseconds since epoch, so this will not yield the correct result. And even if it did, we don't want the SDK to make assumptions about raw data.

Instead, I think we should tailor this logic for each resource type, and only convert dates where we know it is safe to do so.

Sorry for the delay, we have a script which creates tickets in Jira but we forgot to follow up here (we're working on a process to improve this).
Regarding the issue, we agree. It's something we've prioritized and will look into in a couple of weeks.

@hhenriques Any updates on this? It presents invalid data to the user, and should be fixed ASAP.

hi @sebbert! Other priorities just kept pushing this forward... thankfully we have someone working 100% on the JS SDK these next few weeks so we'll be addressing this (and a few other things)

haved commented

Fixed in version 3.0.0 (now released)

hmm, semantic release used to leave this comments automatically.
too bad lerna can't :(