{"record":{"id":"57cba2419ad7f9ca","repo":"apache/druid","slug":"connecturi-cannot-be-null-or-empty","errorCode":null,"errorMessage":"connectURI cannot be null or empty","messagePattern":"connectURI cannot be null or empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/metadata/SQLInputSourceDatabaseConnector.java","lineNumber":92,"sourceCode":"    // We validate only the connection URL here as all properties will be read from only the URL except\n    // users and password. If we want to allow another way to specify user properties such as using\n    // MetadataStorageConnectorConfig.getDbcpProperties(), those properties should be validated as well.\n    validateConfigs(connectorConfig.getConnectURI(), securityConfig);\n    BasicDataSource dataSource = new BasicDataSourceExt(connectorConfig);\n    dataSource.setUsername(connectorConfig.getUser());\n    dataSource.setPassword(connectorConfig.getPassword());\n    String uri = connectorConfig.getConnectURI();\n    dataSource.setUrl(uri);\n    dataSource.setTestOnBorrow(true);\n    dataSource.setValidationQuery(getValidationQuery());\n\n    return dataSource;\n  }\n\n  private void validateConfigs(String urlString, JdbcAccessSecurityConfig securityConfig)\n  {\n    if (Strings.isNullOrEmpty(urlString)) {\n      throw new IllegalArgumentException(\"connectURI cannot be null or empty\");\n    }\n    if (!securityConfig.isEnforceAllowedProperties()) {\n      // You don't want to do anything with properties.\n      return;\n    }\n    final Set<String> propertyKeyFromConnectURL = findPropertyKeysFromConnectURL(urlString, securityConfig.isAllowUnknownJdbcUrlFormat());\n    ConnectionUriUtils.throwIfPropertiesAreNotAllowed(\n        propertyKeyFromConnectURL,\n        securityConfig.getSystemPropertyPrefixes(),\n        securityConfig.getAllowedProperties()\n    );\n  }\n\n  public String getValidationQuery()\n  {\n    return \"SELECT 1\";\n  }\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/SQLInputSourceDatabaseConnector.java#L74-L110","documentation":"SQLInputSourceDatabaseConnector.validateConfigs() validates JDBC connectivity for the SQL input source. It throws IllegalArgumentException when the connectURI string is null or empty, because a JDBC connection cannot be established without a URL. The check precedes the allowed-properties security validation.","triggerScenarios":"Submitting an SQL input-source spec whose connectURI field is missing or empty string; programmatic use of getDatasource() with a null url.","commonSituations":"Hand-written ingestion specs omitting 'connectURI'; templating/variable substitution leaving the URL blank; connector config where the JDBC URL was moved to a different field name.","solutions":["Set a valid JDBC connectURI in the SQL input source spec (e.g. jdbc:mysql://host:3306/db or jdbc:postgresql://host:5432/db).","Check that environment-variable or template substitution actually populated the URL.","Validate the spec with the ingestion-spec validator before submitting."],"exampleFix":"// before\n\"sqlInputSource\": { \"connectURI\": \"\", \"user\": \"u\", \"password\": \"p\" }\n// after\n\"sqlInputSource\": { \"connectURI\": \"jdbc:postgresql://dbhost:5432/druid\", \"user\": \"u\", \"password\": \"p\" }","handlingStrategy":"validation","validationCode":"if (connectURI == null || connectURI.trim().isEmpty()) {\n  throw new IllegalArgumentException(\"sqlInputSource.connectURI is required\");\n}\nif (!connectURI.startsWith(\"jdbc:\")) {\n  throw new IllegalArgumentException(\"connectURI must be a jdbc: URL\");\n}","typeGuard":"boolean hasConnectUri(Map<String, Object> spec) {\n  Object uri = spec.get(\"connectURI\");\n  return uri instanceof String && !((String) uri).isEmpty();\n}","tryCatchPattern":"try {\n  connector.getDatasource(...);\n} catch (IllegalArgumentException e) {\n  log.error(e, \"Invalid SQL input source config: %s\", e.getMessage());\n}","preventionTips":["Validate ingestion specs (Druid's spec validator) before submission","Never leave connectURI blank in templates; fail validation early","Keep JDBC URLs in checked config, not ad-hoc strings"],"tags":["jdbc","config","input-source","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}