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

Illegal input: Fields [promptTokenCount, totalTokenCount] are required for type with serial name #134

Closed
mattttvaughn opened this issue May 3, 2024 · 7 comments
Assignees
Labels
component:android sdk Issue/PR related to Android SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working

Comments

@mattttvaughn
Copy link

I was trying out the SDK and got everything looking GTG, but was unable to get past the error in the title. I then pulled down the sample project and I'm seeing the same error when running the summarization bit, only change is adding my API key to local.properties.

Idk if this is a server-side issue or not but figured I'd log an issue. I tried API keys from accounts with and without whatever Gemini pro access is called, if that's relevant.

OnePlus 8, Android 13

 com.google.ai.client.generativeai.type.SerializationException: Something went wrong while trying to deserialize a response from the server.
2024-05-02 21:43:09.062 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.type.GoogleGenerativeAIException$Companion.from(Exceptions.kt:41)
2024-05-02 21:43:09.063 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.GenerativeModel$generateContentStream$1.invokeSuspend(GenerativeModel.kt:128)
2024-05-02 21:43:09.064 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.GenerativeModel$generateContentStream$1.invoke(Unknown Source:9)
2024-05-02 21:43:09.066 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.GenerativeModel$generateContentStream$1.invoke(Unknown Source:6)
2024-05-02 21:43:09.067 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:115)
2024-05-02 21:43:09.068 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1$1.invokeSuspend(Unknown Source:15)
2024-05-02 21:43:09.069 27617-27617 System.err              com.google.ai.sample                 W  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2024-05-02 21:43:09.070 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)
2024-05-02 21:43:09.071 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith$default(DispatchedContinuation.kt:278)
2024-05-02 21:43:09.072 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.internal.ScopeCoroutine.afterCompletion(Scopes.kt:27)
2024-05-02 21:43:09.072 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.continueCompleting(JobSupport.kt:940)
2024-05-02 21:43:09.074 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.access$continueCompleting(JobSupport.kt:25)
2024-05-02 21:43:09.074 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport$ChildCompletion.invoke(JobSupport.kt:1159)
2024-05-02 21:43:09.075 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1497)
2024-05-02 21:43:09.075 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:325)
2024-05-02 21:43:09.076 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:242)
2024-05-02 21:43:09.076 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.continueCompleting(JobSupport.kt:939)
2024-05-02 21:43:09.077 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.access$continueCompleting(JobSupport.kt:25)
2024-05-02 21:43:09.078 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport$ChildCompletion.invoke(JobSupport.kt:1159)
2024-05-02 21:43:09.078 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1497)
2024-05-02 21:43:09.079 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:325)
2024-05-02 21:43:09.079 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:242)
2024-05-02 21:43:09.080 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:910)
2024-05-02 21:43:09.080 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:867)
2024-05-02 21:43:09.081 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:832)
2024-05-02 21:43:09.082 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
2024-05-02 21:43:09.082 27617-27617 System.err              com.google.ai.sample                 W  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
2024-05-02 21:43:09.083 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
2024-05-02 21:43:09.083 27617-27617 System.err              com.google.ai.sample                 W  	at android.os.Handler.handleCallback(Handler.java:942)
2024-05-02 21:43:09.084 27617-27617 System.err              com.google.ai.sample                 W  	at android.os.Handler.dispatchMessage(Handler.java:99)
2024-05-02 21:43:09.084 27617-27617 System.err              com.google.ai.sample                 W  	at android.os.Looper.loopOnce(Looper.java:240)
2024-05-02 21:43:09.084 27617-27617 System.err              com.google.ai.sample                 W  	at android.os.Looper.loop(Looper.java:351)
2024-05-02 21:43:09.085 27617-27617 System.err              com.google.ai.sample                 W  	at android.app.ActivityThread.main(ActivityThread.java:8412)
2024-05-02 21:43:09.085 27617-27617 System.err              com.google.ai.sample                 W  	at java.lang.reflect.Method.invoke(Native Method)
2024-05-02 21:43:09.086 27617-27617 System.err              com.google.ai.sample                 W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
2024-05-02 21:43:09.086 27617-27617 System.err              com.google.ai.sample                 W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
2024-05-02 21:43:09.089 27617-27617 System.err              com.google.ai.sample                 W  Caused by: kotlinx.serialization.MissingFieldException: Fields [promptTokenCount, totalTokenCount] are required for type with serial name 'com.google.ai.client.generativeai.common.UsageMetadata', but they were missing at path: $.usageMetadata
2024-05-02 21:43:09.090 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:93)
2024-05-02 21:43:09.090 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
2024-05-02 21:43:09.091 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.encoding.AbstractDecoder.decodeNullableSerializableElement(AbstractDecoder.kt:79)
2024-05-02 21:43:09.091 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.GenerateContentResponse$$serializer.deserialize(Response.kt:26)
2024-05-02 21:43:09.092 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.GenerateContentResponse$$serializer.deserialize(Response.kt:26)
2024-05-02 21:43:09.092 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
2024-05-02 21:43:09.092 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)
2024-05-02 21:43:09.093 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1$1.invokeSuspend(ktor.kt:103)
2024-05-02 21:43:09.093 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1$1.invoke(Unknown Source:8)
2024-05-02 21:43:09.094 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1$1.invoke(Unknown Source:4)
2024-05-02 21:43:09.094 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.util.KtorKt.onEachLine(ktor.kt:52)
2024-05-02 21:43:09.095 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1.invokeSuspend(ktor.kt:82)
2024-05-02 21:43:09.095 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1.invoke(Unknown Source:8)
2024-05-02 21:43:09.096 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1.invoke(Unknown Source:4)
2024-05-02 21:43:09.096 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo$suspendImpl(Builders.kt:320)
2024-05-02 21:43:09.096 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo(Unknown Source:0)
2024-05-02 21:43:09.097 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:60)
2024-05-02 21:43:09.097 27617-27617 System.err              com.google.ai.sample                 W  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2024-05-02 21:43:09.098 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
2024-05-02 21:43:09.098 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:68)
2024-05-02 21:43:09.099 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:347)
2024-05-02 21:43:09.099 27617-27617 System.err              com.google.ai.sample                 W  	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:135)
2024-05-02 21:43:09.099 27617-27617 System.err              com.google.ai.sample                 W  	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:109)
2024-05-02 21:43:09.100 27617-27617 System.err              com.google.ai.sample                 W  	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:11)
2024-05-02 21:43:09.100 27617-27617 System.err              com.google.ai.sample                 W  	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:59)
2024-05-02 21:43:09.100 27617-27617 System.err              com.google.ai.sample                 W  	... 10 more
2024-05-02 21:43:09.103 27617-27617 System.err              com.google.ai.sample                 W  Caused by: kotlinx.serialization.MissingFieldException: Fields [promptTokenCount, totalTokenCount] are required for type with serial name 'com.google.ai.client.generativeai.common.UsageMetadata', but they were missing
2024-05-02 21:43:09.103 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20)
2024-05-02 21:43:09.104 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.UsageMetadata.<init>(Response.kt:39)
2024-05-02 21:43:09.104 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.UsageMetadata$$serializer.deserialize(Response.kt:39)
2024-05-02 21:43:09.105 27617-27617 System.err              com.google.ai.sample                 W  	at com.google.ai.client.generativeai.common.UsageMetadata$$serializer.deserialize(Response.kt:39)
2024-05-02 21:43:09.105 27617-27617 System.err              com.google.ai.sample                 W  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:70)
2024-05-02 21:43:09.105 27617-27617 System.err              com.google.ai.sample                 W  	... 34 more
@hoanv810
Copy link

hoanv810 commented May 3, 2024

I'm experiencing the same problem. I suspect it's a server-side bug since everything was functioning normally yesterday.

@singhniraj08 singhniraj08 added type:bug Something isn't working component:android sdk Issue/PR related to Android SDK status:triaged Issue/PR triaged to the corresponding sub-team labels May 3, 2024
@urim85
Copy link

urim85 commented May 3, 2024

I have same.

@dk8996
Copy link

dk8996 commented May 3, 2024

The problem has persisted for nearly 24 hours now. As many of us rely on these APIs for products, is there an SLA in place? Is this production ready?

@ProHussain
Copy link

@mattttvaughn I discovered the same problem with all phones and emulators. Everything was working great earlier, but this morning I ran into this problem, and Google still could not figure it out. How disappointing

@LindaLawton
Copy link

The API just started populating that field yesterday, they are aware of the issue now and trying to get it fixed asap.

@rlazo
Copy link
Collaborator

rlazo commented May 3, 2024

Hey folks, thanks for your reports. We are working on getting the fix out ASAP, stay tuned!

rlazo added a commit that referenced this issue May 3, 2024
Also, exposes the data when available.

Addresses issue #134
@rlazo
Copy link
Collaborator

rlazo commented May 3, 2024

The new release is out https://github.com/google-gemini/generative-ai-android/releases/tag/v0.5.0 It contains the fix this issue. Additionally, we have rolled back the change in the backend that exposed the partial UsageMetadata. This means that even older versions of the SDK will start working again.

Thanks for your patience!

@rlazo rlazo closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:android sdk Issue/PR related to Android SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants