{"record":{"id":"e348a240a6b1dbc8","repo":"apache/druid","slug":"bad-url-s","errorCode":null,"errorMessage":"Bad URL: %s","messagePattern":"Bad URL: (.+?)","errorType":"exception","errorClass":"ISE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/emitter/core/HttpPostEmitter.java","lineNumber":176,"sourceCode":"        config.getMaxBatchSize() >= MAX_EVENT_SIZE + batchOverhead,\n        StringUtils.format(\n            \"maxBatchSize must be greater than MAX_EVENT_SIZE[%,d] + overhead[%,d].\",\n            MAX_EVENT_SIZE,\n            batchOverhead\n        )\n    );\n    this.config = config;\n    this.bufferSize = config.getMaxBatchSize();\n    this.maxBufferWatermark = bufferSize - batchingStrategy.batchEndLength();\n    // Chosen so that if event size < largeEventThreshold, at least 2 events could fit the standard buffer.\n    this.largeEventThreshold = (bufferSize - batchOverhead - batchingStrategy.separatorLength()) / 2;\n    this.client = client;\n    this.jsonMapper = jsonMapper;\n    try {\n      this.url = new URL(config.getRecipientBaseUrl()).toString();\n    }\n    catch (MalformedURLException e) {\n      throw new ISE(e, \"Bad URL: %s\", config.getRecipientBaseUrl());\n    }\n    emittingThread = new EmittingThread(config);\n    long firstBatchNumber = 1;\n    concurrentBatch.set(new Batch(this, acquireBuffer(), firstBatchNumber));\n    // lastBatchFillTimeMillis must not be 0, minHttpTimeoutMillis could be.\n    lastBatchFillTimeMillis = Math.max(config.minHttpTimeoutMillis, 1);\n  }\n\n  @Override\n  @LifecycleStart\n  public void start()\n  {\n    synchronized (startLock) {\n      if (!running) {\n        if (startLatch.getCount() == 0) {\n          throw new IllegalStateException(\"Already started.\");\n        }\n        running = true;","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/emitter/core/HttpPostEmitter.java#L158-L194","documentation":"HttpPostEmitter's constructor validates config.getRecipientBaseUrl() by constructing a java.net.URL. If the URL is malformed (MalformedURLException), it throws IllegalStateException wrapping the exception with 'Bad URL: <url>'. The emitter cannot deliver events without a syntactically valid recipient URL.","triggerScenarios":"Constructing new HttpPostEmitter(config, jsonMapper) when recipientBaseUrl is not a valid absolute URL (missing scheme, illegal characters, etc.).","commonSituations":"URL missing the http:// scheme (e.g. 'metrics-host:8080/druid/metrics'); trailing spaces or embedded quotes from config; hostnames with underscores; config templating leaving placeholder text like ${METRICS_URL} unresolved.","solutions":["Fix the recipientBaseUrl in config to a full absolute URL including scheme, e.g. http://host:8080/druid/metrics","Validate the URL with new URL(value) or URI.create(value) before passing it into config","Check for unresolved environment placeholders or stray whitespace in the property value"],"exampleFix":"// before\nString url = \"metrics-host:8080/druid/metrics\"; // throws Bad URL\n// after\nString url = \"http://metrics-host:8080/druid/metrics\";","handlingStrategy":"validation","validationCode":"String baseUrl = config.getRecipientBaseUrl();\ntry {\n  new java.net.URL(baseUrl);\n} catch (java.net.MalformedURLException e) {\n  throw new IllegalArgumentException(\"recipientBaseUrl must be an absolute URL, got: \" + baseUrl);\n}","typeGuard":"boolean isValidUrl(String s) {\n  if (s == null) return false;\n  try { new java.net.URL(s); return true; } catch (java.net.MalformedURLException e) { return false; }\n}","tryCatchPattern":"try {\n  Emitter e = new HttpPostEmitter(config, mapper);\n} catch (IllegalStateException ex) {\n  log.error(ex, \"Check org.apache.druid.java.util.emitter.http.url value\");\n  throw ex;\n}","preventionTips":["Always include the scheme (http:// or https://) in recipientBaseUrl","Check for unresolved ${PLACEHOLDER} templates or stray whitespace in config","Pre-validate with new URL(value) before constructing the emitter","Avoid hostnames with characters illegal in URLs (e.g. underscores)"],"tags":["url","http","configuration"],"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-14T05:17:10.506Z"}