Skip to content

Kotlin SDK relies on deprecated kotlinx.datetime.Instant, making instantiating mock classes difficult #2079

@salockhart

Description

@salockhart

Bug Report

Version

com.svix.kotlin:svix-kotlin:1.76.1

Platform

Darwin {name omitted} 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64

Description

The ApplicationOut class is defined as follows:

// This file is @generated
package com.svix.kotlin.models

import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable

@Serializable
data class ApplicationOut(
    val createdAt: Instant,
    ...

Here, createdAt (and updatedAt, not visible) rely on the kotlinx.datetime.Instant class to define a datetime.

The kotlinx.datetime.Instant class is deprecated in favour of kotlin.time.Instant, which is functionally identical but unfortunately not able to be used to instantiate an ApplicationOut object.

This makes unit testing difficult - I can pull in the older version of org.jetbrains.kotlinx:kotlinx-datetime in order to get these classes, but they are incompatible with the rest of my codebase.

A possible solution may be to upgrade to org.jetbrains.kotlinx:kotlinx-datetime:0.7.1. In this version, the deprecated types have been aliased to the new ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions