Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize null when passed to a ZiplineService function with a nullable @Contextual parameter #1146

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

veyndan
Copy link
Contributor

@veyndan veyndan commented Oct 16, 2023

No description provided.

@veyndan veyndan requested a review from swankjesse October 16, 2023 14:00
@@ -235,7 +237,7 @@ internal class ArgsListSerializer(
encoder.encodeStructure(descriptor) {
for (i in serializers.indices) {
@Suppress("UNCHECKED_CAST") // We don't have a type argument T for each parameter.
encodeSerializableElement(descriptor, i, serializers[i] as KSerializer<Any?>, value[i])
encodeNullableSerializableElement(descriptor, i, serializers[i] as KSerializer<Any?>, value[i])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An alternative approach is to edit AdapterGenerator such that nullable parameters have their KSerializer's made nullable via https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.builtins/nullable.html. Went with the approach in the PR as it was quicker/easier and is comparable to the other approach.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs added to the README as an additional unstable API that we rely on. Is the nullable API stable? It may be worth the extra effort to reduce our reliance on unstable API in an otherwise stable library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the nullable API stable?

Yep!

I'll have a go at it then in a follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Started a PR at #1149

@swankjesse swankjesse enabled auto-merge (squash) October 16, 2023 14:10
@swankjesse
Copy link
Collaborator

Nice! Thanks for fixing.

@swankjesse swankjesse merged commit 5ef12c0 into trunk Oct 16, 2023
6 checks passed
@swankjesse swankjesse deleted the veyndan/2023-10-16/contextualNullable-fails branch October 16, 2023 15:56
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.

3 participants