Skip to content

CloudStreamPackage: migrate to kotlinx serialization#2878

Open
Luna712 wants to merge 3 commits into
recloudstream:masterfrom
Luna712:migrate7
Open

CloudStreamPackage: migrate to kotlinx serialization#2878
Luna712 wants to merge 3 commits into
recloudstream:masterfrom
Luna712:migrate7

Conversation

@Luna712

@Luna712 Luna712 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@JsonProperty("uri")
@JsonProperty("uri") @SerialName("uri")
@Serializable(with = UriSerializer::class)
val uri: Uri?,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've run into the first null issue from #2897

Java.lang.AssertionError: Serialization mismatch for:
com.lagradost.cloudstream3.actions.temp.CloudStreamPackage.MinimalVideoLink

Jackson:
{"uri":null,"url":"YRZOHJ","mimeType":"QSIUJMXEP","name":"NHOIYX","headers":{"UDHQNR":"CZDV","CQTCZKYKWN":"KGRYBRD","DXAOWNP":"XDQXGLZAOC"},"quality":1779}

Kotlinx:
{"url":"YRZOHJ","mimeType":"QSIUJMXEP","name":"NHOIYX","headers":{"UDHQNR":"CZDV","CQTCZKYKWN":"KGRYBRD","DXAOWNP":"XDQXGLZAOC"},"quality":1779}

However, this can be sidestepped by making Instancio create a valid Uri-type (we should really have this for all troublesome types):

val instance = Instancio.of(kClass.java).lenient().supply(all(Uri::class.java), Supplier {
    Uri.parse("https://example.com")
}).create()

But this gives

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle (through reference chain: com.lagradost.cloudstream3.actions.temp.CloudStreamPackage$MinimalVideoLink["uri"]->android.net.Uri$StringUri["canonicalUri"])

Meaning that Jackson actually cannot serialize it properly 😬
Perhaps we also need custom JsonDeserializer for jackson? What do you think is best?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I think the best option here is to add a temporary annotation that can skip certain classes in tests and drop worrying about Jackson for things like this. I feel focusing on fixing Jackson to match kotlinx exactly is a waste of time for things like this when Jackson is being phased out. But it is up to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants