apache/beam · error · IllegalArgumentException

Cannot create enum from value!

Error message

Cannot create enum from  value!

What it means

Connectors.fromName maps a connector name string to the Connectors enum by iterating values() and comparing getName(); if no enum constant matches it throws IllegalArgumentException. This is the enum lookup used when configuring a Debezium read.

Source

Thrown at sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/Connectors.java:69

          String.format(
              "Unable to resolve class %s to use as Debezium connector.", this.connector));
    }
    return connectorClass;
  }

  /**
   * Returns a connector class corresponding to the given connector name.
   *
   * @param connectorName The name of the connector. Ex.: MySQL
   * @return Connector enum representing the given connector name.
   */
  public static Connectors fromName(String connectorName) {
    for (Connectors connector : Connectors.values()) {
      if (connector.getName().equals(connectorName)) {
        return connector;
      }
    }
    throw new IllegalArgumentException("Cannot create enum from " + connectorName + " value!");
  }
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Use the exact connector name as defined by the Connectors enum (check getName() of its constants).
  2. Check the enum's values() to see supported connectors and pick one.
  3. Normalize case before lookup: Connectors.fromName(cfg.trim().toUpperCase(Locale.ROOT)) if applicable.
  4. If the engine is genuinely unsupported, read via Kafka Connect directly instead of this enum.

Example fix

// before
Connectors c = Connectors.fromName(config.get("engine")); // "mysql" -> throws
// after
Connectors c = Connectors.fromName(config.get("engine").trim().toUpperCase(Locale.ROOT)); // "MYSQL"
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Arrays.stream(Connectors.values()).map(Connectors::getName).collect(Collectors.toSet());
if (!valid.contains(connectorName.trim())) throw new IllegalArgumentException("Supported: " + valid);

Type guard

static boolean isKnownConnector(String name) {
  return Arrays.stream(Connectors.values()).anyMatch(c -> c.getName().equals(name));
}

Prevention

When it happens

Trigger: Calling Connectors.fromName with a string that is not one of the supported connector names (e.g. "mysql" vs "MYSQL", or an unsupported engine like "oracle").

Common situations: Case mismatch between user config and enum name, passing the connector class name instead of the enum name, or using a database engine the Beam Debezium wrapper does not enumerate.

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/d2f4742e97d7854d. Report an issue: GitHub.