testcontainers/testcontainers-java · warning · IllegalArgumentException

Unexpected outputType

Error message

Unexpected outputType ${outputType}

What it means

Slf4jLogConsumer.accept() switches on the Docker frame OutputType (STDOUT/STDERR) to pick the log level. Any OutputType outside the handled cases — or an accept() call made after the consumer was composed/filtered in an unexpected way — hits the default branch and throws IllegalArgumentException("Unexpected outputType " + outputType).

Solutions

  1. Check the Docker Engine version; upgrade Testcontainers to match its API.
  2. Log the actual outputType value from the message to identify the unexpected frame type.
  3. Wrap the consumer to sanitize frames before passing to Slf4jLogConsumer.
  4. Report the issue to Testcontainers if it comes from a normal `followOutput` stream.
Defensive patterns

Strategy: try-catch

Try / catch

container.followOutput(frame -> { try { consumer.accept(frame); } catch (IllegalArgumentException e) { log.warn("skipped frame with outputType {}", frame.getType()); } });

Prevention

When it happens

Trigger: Following a container's log stream and receiving a frame whose OutputType is neither STDOUT nor STDERR (e.g. unexpected Docker API response), or programmatic misuse passing a foreign OutputType to accept().

Common situations: Rare in practice; appears with unusual Docker Engine versions returning unexpected frame types, or custom code feeding frames into the consumer.

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 testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/f0e53ec7f4e152f8. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/testcontainers/containers/output/Slf4jLogConsumer.java:77

            switch (outputType) {
                case END:
                    break;
                case STDOUT:
                    if (separateOutputStreams) {
                        logger.info("{}{}", prefix.isEmpty() ? "" : (prefix + ": "), utf8String);
                    } else {
                        logger.info("{}{}: {}", prefix, outputType, utf8String);
                    }
                    break;
                case STDERR:
                    if (separateOutputStreams) {
                        logger.error("{}{}", prefix.isEmpty() ? "" : (prefix + ": "), utf8String);
                    } else {
                        logger.info("{}{}: {}", prefix, outputType, utf8String);
                    }
                    break;
                default:
                    throw new IllegalArgumentException("Unexpected outputType " + outputType);
            }
        } finally {
            if (originalMdc == null) {
                MDC.clear();
            } else {
                MDC.setContextMap(originalMdc);
            }
        }
    }
}

View on GitHub (pinned to 8e549514e3)