apache/beam · error · IllegalArgumentException

Unsupported type of %s: %s

Error message

Unsupported type of %s: %s

What it means

TestStreamTranslation.eventToProto converts a TestStream.Event into its RunnerApi proto representation via a switch over the event type. If the event's getType() is not one of the known element/processing-time/watermark types, no case matches and the default branch throws IllegalArgumentException with the unknown type.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/TestStreamTranslation.java:130

                        ((TestStream.ProcessingTimeEvent<T>) event)
                            .getProcessingTimeAdvance()
                            .getMillis()))
            .build();

      case ELEMENT:
        RunnerApi.TestStreamPayload.Event.AddElements.Builder builder =
            RunnerApi.TestStreamPayload.Event.AddElements.newBuilder();
        for (TimestampedValue<T> element : ((TestStream.ElementEvent<T>) event).getElements()) {
          builder.addElements(
              RunnerApi.TestStreamPayload.TimestampedElement.newBuilder()
                  .setTimestamp(element.getTimestamp().getMillis())
                  .setEncodedElement(
                      ByteString.copyFrom(
                          CoderUtils.encodeToByteArray(coder, element.getValue()))));
        }
        return RunnerApi.TestStreamPayload.Event.newBuilder().setElementEvent(builder).build();
      default:
        throw new IllegalArgumentException(
            String.format(
                "Unsupported type of %s: %s",
                TestStream.Event.class.getCanonicalName(), event.getType()));
    }
  }

  static <T> TestStream.Event<T> eventFromProto(
      RunnerApi.TestStreamPayload.Event protoEvent, Coder<T> coder) throws IOException {
    switch (protoEvent.getEventCase()) {
      case WATERMARK_EVENT:
        return TestStream.WatermarkEvent.advanceTo(
            new Instant(protoEvent.getWatermarkEvent().getNewWatermark()));
      case PROCESSING_TIME_EVENT:
        return TestStream.ProcessingTimeEvent.advanceBy(
            Duration.millis(protoEvent.getProcessingTimeEvent().getAdvanceDuration()));
      case ELEMENT_EVENT:
        List<TimestampedValue<T>> decodedElements = new ArrayList<>();
        for (RunnerApi.TestStreamPayload.TimestampedElement element :

View on GitHub (pinned to 12126d8942)

Solutions

  1. Check the TestStream construction so every added event is a supported ElementEvent/ProcessingTimeEvent/WatermarkEvent
  2. Rebuild against a Beam version whose eventToProto knows the event type
  3. Inspect the event for null/corrupted payload before translation

Example fix

// before
TestStream<Long> ts = TestStream.create(coder).addElements(1L).advanceWatermarkToInfinity();
// ensure events are well-formed; avoid building events via raw protos with EVENT_NOT_SET
// after
TestStream<Long> ts = TestStream.create(coder)
    .addElements(1L)
    .advanceProcessingDuration(Duration.millis(10))
    .advanceWatermarkToInfinity();
Defensive patterns

Strategy: validation

Validate before calling

// Verify each event in the TestStream is a supported concrete type before translation:
for (TestStream.Event<?> e : testStream.getEvents()) {
  boolean ok = e instanceof TestStream.ElementEvent
      || e instanceof TestStream.ProcessingTimeEvent
      || e instanceof TestStream.WatermarkEvent;
  if (!ok) throw new IllegalStateException("Unsupported TestStream event: " + e);
}

Try / catch

try { translateToProto(stream); } catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Unsupported type of")) { /* rebuild stream with known event types */ }
  else throw e;
}

Prevention

When it happens

Trigger: Translating a TestStream whose event is EVENT_NOT_SET or a type added in a newer Beam version than the translator supports, typically when converting a pipeline containing TestStream to a RunnerApi proto.

Common situations: Proto deserialization produced an unset/default event; running tests across mismatched Beam SDK versions where new event kinds exist but the translator predates them.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/84b8db7738bff816. Report an issue: GitHub.