temporalio / sdk-java

Temporal Java SDK
https://temporal.io
Apache License 2.0
209 stars 142 forks source link

WorkflowHistoryLoader fails to load decoded event history #2109

Closed ddavidyuk closed 3 months ago

ddavidyuk commented 3 months ago

Expected Behavior

WorkflowHistoryLoader should be able to load history from a file downloaded via Temporal UI / Temporal Cloud UI with "Decode History" option.

Actual Behavior

WorkflowHistoryLoader fails when loading a file downloaded via Temporal UI / Temporal Cloud UI with "Decode History" option.

Steps to Reproduce the Problem

  1. Open any completed workflow execution in Temporal UI or Temporal Cloud UI
  2. Click Download History with checked "Decode History" option.
  3. Try to load the history from the downloaded file via WorkflowHistoryLoader API: WorkflowHistoryLoader.readHistory(<path to the history JSON file>)
  4. WorkflowHistoryLoader fails with this exception (the actual payload replaced with ..., cannot provide it here):
    io.temporal.common.converter.DataConverterException: com.google.protobuf.InvalidProtocolBufferException: Invalid value: {...} for expected type: BYTES
    at io.temporal.common.WorkflowExecutionHistory.fromJson(WorkflowExecutionHistory.java:79)
    at io.temporal.common.WorkflowExecutionHistory.fromJson(WorkflowExecutionHistory.java:63)
    at io.temporal.testing.WorkflowHistoryLoader.readHistory(WorkflowHistoryLoader.java:60)
    ...
    Caused by: com.google.protobuf.InvalidProtocolBufferException: Invalid value: {...} for expected type: BYTES
    at com.google.protobuf.util.JsonFormat$ParserImpl.parseFieldValue(JsonFormat.java:1971)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1669)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1500)
    at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1458)
    at com.google.protobuf.util.JsonFormat$ParserImpl.parseFieldValue(JsonFormat.java:2018)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeRepeatedField(JsonFormat.java:1733)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1665)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1500)
    at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1458)
    at com.google.protobuf.util.JsonFormat$ParserImpl.parseFieldValue(JsonFormat.java:2018)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1669)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1500)
    at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1458)
    at com.google.protobuf.util.JsonFormat$ParserImpl.parseFieldValue(JsonFormat.java:2018)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeOneofField(JsonFormat.java:1708)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1667)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1500)
    at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1458)
    at com.google.protobuf.util.JsonFormat$ParserImpl.parseFieldValue(JsonFormat.java:2018)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeRepeatedField(JsonFormat.java:1733)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeField(JsonFormat.java:1665)
    at com.google.protobuf.util.JsonFormat$ParserImpl.mergeMessage(JsonFormat.java:1500)
    at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1458)
    at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1340)
    at com.google.protobuf.util.JsonFormat$Parser.merge(JsonFormat.java:472)
    at io.temporal.common.WorkflowExecutionHistory.fromJson(WorkflowExecutionHistory.java:77)

Specifications

Additional details

We are testing our encrypting / compressing DataConverter, and would like to be able to download decoded event history for local testing with WorkflowReplayer class (to make sure the changes we make to our workflows are compatible with prior event histories).

Quinn-With-Two-Ns commented 3 months ago

The UI "Decode History" is designed for human consumption not SDK consumption and is not intended to be compatible with SDKs so it is not expected to work. Our docs generally recommend downloading history from the CLI or SDK to replay https://docs.temporal.io/develop/java/testing-suite#replay.

We do also plan to add utilities inside the SDK to make it easier to decode encrypted payloads in history to make replay easier as well.

https://github.com/temporalio/features/issues/468