temporalio / temporalio/sdk-java

ProtobufJsonPayloadConverter does not work correctly with shaded artifact

Open
#2,792 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
433
Forks
249
Avg merge
5d 6h
Merged PRs (30d)
26

Description

Expected Behavior

The ProtobufJsonPayloadConverter does not work correctly when using the shaded Temporal artifact, which is sometimes necessary to avoid gRPC version conflicts.

The problem is: https://github.com/temporalio/sdk-java/blob/81f3cc33be8c4d6dbda48321cbb0b7aee3915e31/temporal-sdk/src/main/java/io/temporal/common/converter/ProtobufJsonPayloadConverter.java#L51-L53

Here, MessageOrBuilder is rewritten in the byte-code to be io.temporal.shaded.com.google.protobuf.MessageOrBuilder, and so passing in a non-shaded value (as certainly client code will be using) fails, and the converter fails to convert the value.

The converter, whether it is shaded or not, should correctly recognize protobuf values coming from client code.

Actual Behavior

Protobuf values coming from client code are ignored, and serialization fails.

Steps to Reproduce the Problem

Using the shaded temporal artifact, run this code:

import com.google.protobuf.StringValue;
import io.temporal.common.converter.ProtobufJsonPayloadConverter;

class Test {
    public static void main(String[] args) {
        var converter = new ProtobufJsonPayloadConverter();
        var msg = StringValue.of("hello");
        var payloadOpt = converter.toData(msg);
        System.out.println(payloadOpt.isPresent());
    }
}

We can see that the payload is not present.

Specifications

  • Version: 1.32.1
  • Platform: N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with temporal-sdk/src/main/java/io/temporal/common/converter/ProtobufJsonPayloadConverter.java at the MessageOrBuilder check described in the issue. Run the shaded-artifact reproduction using StringValue.of("hello") and verify the converter's payload result. Done means protobuf values from client code are recognized and the reproduction reports a present payload in the shaded artifact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.