{"record":{"id":"298a999019f67cce","repo":"apache/beam","slug":"jdbc-url-cannot-be-blank","errorCode":null,"errorMessage":"JDBC URL cannot be blank","messagePattern":"JDBC URL cannot be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java","lineNumber":404,"sourceCode":"    @Nullable\n    public abstract String getReadQuery();\n\n    @SchemaFieldDescription(\n        \"Secret Manager to use for fetching secret values. Available options: 'GoogleCloudSecretManager', 'GoogleCloudHsmGeneratedSecretManager'. If not set, no secret manager is used and the password is treated as a plain password.\")\n    @Nullable\n    public abstract String getSecretManager();\n\n    @SchemaFieldDescription(\"Username for the JDBC source.\")\n    @Nullable\n    public abstract String getUsername();\n\n    public void validate() {\n      validate(\"\");\n    }\n\n    public void validate(String jdbcType) throws IllegalArgumentException {\n      if (Strings.isNullOrEmpty(getJdbcUrl())) {\n        throw new IllegalArgumentException(\"JDBC URL cannot be blank\");\n      }\n\n      jdbcType = !Strings.isNullOrEmpty(jdbcType) ? jdbcType : getJdbcType();\n\n      boolean driverClassNamePresent = !Strings.isNullOrEmpty(getDriverClassName());\n      boolean driverJarsPresent = !Strings.isNullOrEmpty(getDriverJars());\n      boolean jdbcTypePresent = !Strings.isNullOrEmpty(jdbcType);\n      if (!driverClassNamePresent && !driverJarsPresent && !jdbcTypePresent) {\n        throw new IllegalArgumentException(\n            \"If JDBC type is not specified, then Driver Class Name and Driver Jars must be specified.\");\n      }\n      if (!driverClassNamePresent && !jdbcTypePresent) {\n        throw new IllegalArgumentException(\n            \"One of JDBC Driver class name or JDBC type must be specified.\");\n      }\n      if (jdbcTypePresent\n          && !JDBC_DRIVER_MAP.containsKey(Objects.requireNonNull(jdbcType).toLowerCase())) {\n        throw new IllegalArgumentException(\"JDBC type must be one of \" + JDBC_DRIVER_MAP.keySet());","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java#L386-L422","documentation":"JdbcReadSchemaTransformProvider's configuration validator requires a non-empty JDBC URL. Before any other checks, validate() uses Strings.isNullOrEmpty(getJdbcUrl()) and throws IllegalArgumentException if the URL is blank. This fails fast at pipeline construction instead of at runtime connection time.","triggerScenarios":"Building a JdbcReadSchemaTransform (including SqlServerReadSchemaTransform) via from()/validate() without setting jdbcUrl, or setting it to null/empty string.","commonSituations":"Constructing the transform map/config programmatically and forgetting the jdbcUrl key, YAML/JSON config missing the field, or a template variable (e.g. ${DB_URL}) resolving to empty.","solutions":["Set the jdbcUrl field on the configuration, e.g. jdbc:mysql://host:3306/db.","If loading from config file/environment, check the value is populated before building the transform.","Wrap validate() in a config pre-check that surfaces which required field is missing."],"exampleFix":"// before\nJdbcReadSchemaTransformProvider.JdbcReadSchemaTransformConfiguration.builder().setReadQuery(q).build()\n// after\n...builder().setReadQuery(q).setJdbcUrl(\"jdbc:postgresql://localhost:5432/mydb\").build()","handlingStrategy":"validation","validationCode":"if (config.getJdbcUrl() == null || config.getJdbcUrl().isBlank()) {\n  throw new IllegalArgumentException(\"jdbcUrl is required, e.g. jdbc:postgresql://host:5432/db\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (\"JDBC URL cannot be blank\".equals(e.getMessage())) {\n    throw new IllegalStateException(\"Missing jdbcUrl in transform config\", e);\n  }\n  throw e;\n}","preventionTips":["Fail config loading early with explicit checks for required fields.","Interpolate environment variables before validate() so empty substitutions surface immediately.","Document required keys in config templates."],"tags":["jdbc","java","validation","configuration"],"backgroundTag":"empty-required-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}