{"record":{"id":"d2f4742e97d7854d","repo":"apache/beam","slug":"cannot-create-enum-from-value","errorCode":null,"errorMessage":"Cannot create enum from  value!","messagePattern":"Cannot create enum from  value!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/Connectors.java","lineNumber":69,"sourceCode":"          String.format(\n              \"Unable to resolve class %s to use as Debezium connector.\", this.connector));\n    }\n    return connectorClass;\n  }\n\n  /**\n   * Returns a connector class corresponding to the given connector name.\n   *\n   * @param connectorName The name of the connector. Ex.: MySQL\n   * @return Connector enum representing the given connector name.\n   */\n  public static Connectors fromName(String connectorName) {\n    for (Connectors connector : Connectors.values()) {\n      if (connector.getName().equals(connectorName)) {\n        return connector;\n      }\n    }\n    throw new IllegalArgumentException(\"Cannot create enum from \" + connectorName + \" value!\");\n  }\n}\n","sourceCodeStart":51,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/Connectors.java#L51-L72","documentation":"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.","triggerScenarios":"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\").","commonSituations":"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.","solutions":["Use the exact connector name as defined by the Connectors enum (check getName() of its constants).","Check the enum's values() to see supported connectors and pick one.","Normalize case before lookup: Connectors.fromName(cfg.trim().toUpperCase(Locale.ROOT)) if applicable.","If the engine is genuinely unsupported, read via Kafka Connect directly instead of this enum."],"exampleFix":"// before\nConnectors c = Connectors.fromName(config.get(\"engine\")); // \"mysql\" -> throws\n// after\nConnectors c = Connectors.fromName(config.get(\"engine\").trim().toUpperCase(Locale.ROOT)); // \"MYSQL\"","handlingStrategy":"validation","validationCode":"Set<String> valid = Arrays.stream(Connectors.values()).map(Connectors::getName).collect(Collectors.toSet());\nif (!valid.contains(connectorName.trim())) throw new IllegalArgumentException(\"Supported: \" + valid);","typeGuard":"static boolean isKnownConnector(String name) {\n  return Arrays.stream(Connectors.values()).anyMatch(c -> c.getName().equals(name));\n}","tryCatchPattern":null,"preventionTips":["Match the enum constant name exactly, including case.","Normalize input with trim()/toUpperCase() before lookup.","Keep connector name config values sourced from the enum, not free text."],"tags":["java","apache-beam","debezium","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}