Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Live API: fractional-second Durations ("7.280s") fail to deserialize, dropping the whole message

Aperta
#1,120 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@hemasekhar-p ci sta già lavorando.

Dal 21/7/2026.

  • #1121 di @davetraction — aperta
  • #1340 di @copybara-service — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

priority: p2 type: bug
Description

CustomDurationDeserializer in JsonSerializable only parses whole-second Duration values (Long.parseLong), but the Gemini Live API server streams fractional-second Durations (e.g. "7.280s", "1.600s", "0.360s"). The parse throws NumberFormatException, which surfaces as:

SEVERE: Error deserializing message
com.google.genai.errors.GenAiIOException: Failed to deserialize the JSON node.
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:
  Cannot deserialize value of type `java.time.Duration` from String "7.280s":
  Cannot parse duration from string: 7.280s. Expected format 'Xs'.

Because this happens inside the Live WebSocket read path, the entire server message is dropped. When that message carries the model turn / a function call, the turn is lost — in a voice-agent app the assistant cuts off mid-sentence and no tool call fires.

Impact

Production voice-reception app on gemini-3.1-flash-live-preview (Vertex): ~700 of these errors in 24h across ~190 calls (~3–4 per call). Most calls survive because the read loop resumes on the next message, but an intermittent few break at the worst moment (mid first response / on the transfer tool call).

Root cause

src/main/java/com/google/genai/JsonSerializable.java, CustomDurationDeserializer:

long seconds = Long.parseLong(secondsPart);   // rejects "7.280"
return java.time.Duration.ofSeconds(seconds);
Suggested fix

Parse decimal seconds and keep sub-second precision:

double seconds = Double.parseDouble(secondsPart);
return java.time.Duration.ofNanos(Math.round(seconds * 1_000_000_000.0));

(Protobuf google.protobuf.Duration is routinely JSON-encoded with fractional seconds, so this is the expected wire format.)

Versions
  • google-genai 1.61.0 (also present in 1.62.0 — JsonSerializable unchanged)
  • Model: gemini-3.1-flash-live-preview, Vertex AI, Live API (BidiGenerateContent)
  • Java 25
Lingua principale
Java
Stelle
398
Fork
126
Merge medio
1g 12h
PR unite (30g)
71

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleapis/java-genai

Tutte le issue di googleapis/java-genai

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.