googleapis / google-cloud-java

Google Cloud Client Library for Java
https://cloud.google.com/java/docs/reference
Apache License 2.0
1.86k stars 1.06k forks source link

ITChatSessionIntegrationTest failed with IllegalStateException (flaky) #10984

Open zhumin8 opened 1 week ago

zhumin8 commented 1 week ago

ITChatSessionIntegrationTest:sendMessageMixedStreamAndUnary_historyOfFour and ITChatSessionIntegrationTest.sendMessageMixedStreamAndUnary_historyOfFour failed with IllegalStateException in GraalVM JDK 17 Nightly

Failures (2):
  JUnit Vintage:ITChatSessionIntegrationTest:sendMessageMixedStreamAndUnary_historyOfFour
    MethodSource [className = 'com.google.cloud.vertexai.it.ITChatSessionIntegrationTest', methodName = 'sendMessageMixedStreamAndUnary_historyOfFour', methodParameterTypes = '']
    => java.lang.IllegalStateException: Rerun getHistory() to get cleaned history.
       com.google.cloud.vertexai.generativeai.ChatSession.getHistory(ChatSession.java:357)
       com.google.cloud.vertexai.it.ITChatSessionIntegrationTest.sendMessageMixedStreamAndUnary_historyOfFour(ITChatSessionIntegrationTest.java:120)
       java.base@17.0.8/java.lang.reflect.Method.invoke([Method.java:568](https://cs.corp.google.com/#search/&sq=package:%5Epiper$%20project:openjdk21&q=java/lang/reflect/Method.java:568))
     Caused by: java.lang.IllegalStateException: The last round of conversation will not be added to history because response stream did not finish normally. Finish reason is RECITATION.
       com.google.cloud.vertexai.generativeai.ChatSession.checkFinishReasonAndEditHistory(ChatSession.java:339)
       com.google.cloud.vertexai.generativeai.ChatSession.lambda$checkLastResponseAndEditHistory$0(ChatSession.java:308)
       java.base@17.0.8/java.util.Optional.ifPresent([Optional.java:178](https://cs.corp.google.com/#search/&sq=package:%5Epiper$%20project:openjdk21&q=java/util/Optional.java:178))
       com.google.cloud.vertexai.generativeai.ChatSession.checkLastResponseAndEditHistory(ChatSession.java:305)
       com.google.cloud.vertexai.generativeai.ChatSession.getHistory(ChatSession.java:353)
       [...]
  JUnit Vintage:ITChatSessionIntegrationTest:sendMessageWithNewConfigs_historyContainsFullConversation
    MethodSource [className = 'com.google.cloud.vertexai.it.ITChatSessionIntegrationTest', methodName = 'sendMessageWithNewConfigs_historyContainsFullConversation', methodParameterTypes = '']
    => java.lang.IllegalStateException: The last round of conversation will not be added to history because response stream did not finish normally. Finish reason is RECITATION.
       com.google.cloud.vertexai.generativeai.ChatSession.checkFinishReasonAndEditHistory(ChatSession.java:339)
       com.google.cloud.vertexai.generativeai.ChatSession.lambda$checkLastResponseAndEditHistory$1(ChatSession.java:323)
       java.base@17.0.8/java.util.Optional.ifPresent([Optional.java:178](https://cs.corp.google.com/#search/&sq=package:%5Epiper$%20project:openjdk21&q=java/util/Optional.java:178))
       com.google.cloud.vertexai.generativeai.ChatSession.checkLastResponseAndEditHistory(ChatSession.java:316)
       com.google.cloud.vertexai.generativeai.ChatSession.sendMessage(ChatSession.java:243)
       com.google.cloud.vertexai.generativeai.ChatSession.sendMessage(ChatSession.java:233)

see log for details. This was resolved in rebuild.

Previously wrongly opened issue in https://github.com/googleapis/sdk-platform-java/issues/2931