Timestamps from the API seem to get deserialized wrongly

Open
#29 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, kotlin
Domain
api, backend

Research direction

Start with the objectMapper used by the SDK to deserialize V2 API responses, then reproduce the issue using the UpdateUsersRequest example and the returned createdAt and updatedAt fields. Confirm the timestamp unit used by the API and verify that microsecond timestamps are converted to the correct dates rather than producing year 55808194.

Written by the indexing model from the issue text.

Description

I will just lead with some example code (it's kotlin, hope its okay, but the gist should be clear)

fun main() {
  val client = StreamSDKClient()
  val updateUsersRequest = UpdateUsersRequest().apply {
    users = mapOf("test" to UserRequest().apply {
      id = "tester"
      name = "Tester"
    })
  }
  client.updateUsers(
    updateUsersRequest
  ).execute().data.users.forEach {
    println(it)
  }
}

The output looks like this:

tester=FullUserResponse(banned=false, createdAt=Thu May 22 23:25:49 CEST 55808194, id=tester, invisible=false, language=, online=false, role=user, shadowBanned=false, totalUnreadCount=0, unreadChannels=0, unreadCount=0, unreadThreads=0, updatedAt=Thu May 22 23:25:49 CEST 55808194, blockedUserIds=[], channelMutes=[], devices=[], mutes=[], teams=[], custom={}, avgResponseTime=null, banExpires=null, deactivatedAt=null, deletedAt=null, image=null, lastActive=null, name=Tester, revokeTokensIssuedBefore=null, latestHiddenChannels=null, privacySettings=null, teamsRole=null)

As you see, the date is completely off: createdAt=Thu May 22 23:25:49 CEST 55808194 which is (roughly, maybe due to precission issues) the value if you multiply the current timestamp with 1e6.

The reasons seems to be that the V2 api responds with timestamps in microseconds resulution (e.g. 1761074344387549000), but the objectMapper the SDK is using to deserialize the response is not configured to understand these timestamps.

It's not a grave issue for us since we are not using this timestamp. I just noticed and thought I should share.

Dominant language
Java
Stars
3
Forks
2
Avg merge
18h 29m
Merged PRs (30d)
19

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GetStream/stream-sdk-java

All issues in GetStream/stream-sdk-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.