{"record":{"id":"5bbb6eaf9f819dc8","repo":"apache/druid","slug":"parametrizeduriextractor-with-pattern-s-requires","errorCode":null,"errorMessage":"ParametrizedUriExtractor with pattern %s requires %s to be set in event, but found %s","messagePattern":"ParametrizedUriExtractor with pattern (.+?) requires (.+?) to be set in event, but found (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/emitter/core/ParametrizedUriExtractor.java","lineNumber":61,"sourceCode":"    while (keyMatcher.find()) {\n      params.add(keyMatcher.group(1));\n    }\n  }\n\n  public Set<String> getParams()\n  {\n    return params;\n  }\n\n  @Override\n  public URI apply(Event event) throws URISyntaxException\n  {\n    Map<String, Object> eventMap = event.toMap();\n    String processedUri = uriPattern;\n    for (String key : params) {\n      Object paramValue = eventMap.get(key);\n      if (paramValue == null) {\n        throw new IAE(\n            \"ParametrizedUriExtractor with pattern %s requires %s to be set in event, but found %s\",\n            uriPattern,\n            key,\n            eventMap\n        );\n      }\n      processedUri = StringUtils.replace(processedUri, StringUtils.format(\"{%s}\", key), paramValue.toString());\n    }\n    return new URI(processedUri);\n  }\n\n  @Override\n  public String toString()\n  {\n    return \"ParametrizedUriExtractor{\" +\n           \"uriPattern='\" + uriPattern + '\\'' +\n           \", params=\" + params +\n           '}';","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/emitter/core/ParametrizedUriExtractor.java#L43-L79","documentation":"ParametrizedUriExtractor builds the target URI by substituting placeholders in a URI pattern with values from the event map. If any required placeholder key is absent (or null) in the event, apply() throws IllegalArgumentException naming the pattern, the missing key, and the event map. It is a per-event data validation failure inside the emitter framework.","triggerScenarios":"Configuring a parametrized feed URI (e.g. feed pattern containing {feed} or {dataSource}) and emitting an event whose toMap() lacks that key; events of a different type routed to a parametrized feed via SwitchingEmitter.","commonSituations":"Custom events that don't carry the 'feed' field routed to a ParametrizedUriExtractor; renaming event fields in custom metric emitters; misconfigured emitter JSON where the URI pattern expects fields only some events have.","solutions":["Ensure emitted events contain all keys referenced by the URI pattern (e.g. set 'feed' on the event).","Route such events to a different extractor/feed in the SwitchingEmitter config.","Simplify the URI pattern to only use keys guaranteed on all events.","Add a null/containsKey check on the event map before emitting to that extractor."],"exampleFix":"// before\nServiceMetricEvent.builder().setMetric(\"query/time\", 10).build(); // no feed\n// after\nServiceMetricEvent.builder().setFeed(\"feed\").setMetric(\"query/time\", 10).build();","handlingStrategy":"validation","validationCode":"Map<String, Object> eventMap = event.toMap();\nfor (String key : requiredUriParams) {\n  if (eventMap.get(key) == null) {\n    throw new IllegalArgumentException(\"Event missing required URI param: \" + key);\n  }\n}","typeGuard":"boolean hasAllParams(Event event, java.util.List<String> keys) {\n  Map<String, Object> m = event.toMap();\n  return keys.stream().allMatch(k -> m.get(k) != null);\n}","tryCatchPattern":"try {\n  extractor.apply(event);\n} catch (IllegalArgumentException e) {\n  log.error(e, \"Event lacks fields required by URI pattern; routing to default feed\");\n}","preventionTips":["Match extractor URI params to fields actually set on events","Set 'feed' (and any other placeholders) on every event","Route heterogeneous events via SwitchingEmitter to appropriate extractors"],"tags":["emitter","uri-extraction","missing-field","event"],"backgroundTag":"missing-required-argument","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}