{"record":{"id":"4475475bc4c30c2a","repo":"apache/druid","slug":"s-dynamic-msg-passed-to-invalidinput-exception","errorCode":null,"errorMessage":"%s (dynamic msg passed to InvalidInput.exception)","messagePattern":"(.+?) \\(dynamic msg passed to InvalidInput\\.exception\\)","errorType":"validation","errorClass":"DruidException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/error/InvalidInput.java","lineNumber":50,"sourceCode":"    return exception(null, msg, args);\n  }\n\n  public static DruidException exception(Throwable t, String msg, Object... args)\n  {\n    return DruidException.fromFailure(new InvalidInput(t, msg, args));\n  }\n\n  /**\n   * evalues a condition. If it's false, it throws the appropriate DruidException\n   *\n   * @param condition - boolean condition to validate\n   * @param msg - passed through to DruidException.exception()\n   * @param args - passed through to DruidException.exception()\n   */\n  public static void conditionalException(boolean condition, String msg, Object... args)\n  {\n    if (!condition) {\n      throw exception(msg, args);\n    }\n  }\n\n  public static <T> T notNull(@Nullable T val, String name)\n  {\n    InvalidInput.conditionalException(val != null, \"%s must not be null\", name);\n    return val;\n  }\n\n  /**\n   * evalues a condition. If it's false, it throws the appropriate DruidException with a given cause\n   *\n   * @param condition - boolean condition to validate\n   * @param t - throwable to pass to InvalidInput.exception()\n   * @param msg - passed through to InvalidInput.exception()\n   * @param args - passed through to InvalidInput.exception()\n   */\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/error/InvalidInput.java#L32-L68","documentation":"InvalidInput.conditionalException(condition, msg, args) throws an InvalidInput DruidException (user-persona, 400-class) when the condition is false. It is Druid's convenience guard for caller-supplied values; the placeholder message here is replaced by the dynamic msg passed at the call site (e.g., '%s must not be null'). Seeing it means an argument you supplied failed a validity check.","triggerScenarios":"Any Druid API that calls InvalidInput.conditionalException(cond, ...) with a false condition — typically null or malformed inputs such as passing null to InvalidInput.notNull(val, name) or otherwise invalid configuration/JSON fields.","commonSituations":"Omitting a required field in a spec JSON; passing null for a required parameter; supplying values of the wrong format to ingestion/query spec builders; typos in field names causing defaults to be null.","solutions":["Read the dynamic message to identify which argument/field failed validation.","Supply the missing or corrected value required by the failing check.","Validate the spec JSON against the Druid schema/docs before submission.","If you believe the input is valid, verify field names and casing match the current Druid version's API."],"exampleFix":"// before: null required argument\nIngestionSpec.builder().dataSource(null).build();\n// after: provide required field\nIngestionSpec.builder().dataSource(\"wikipedia\").build();","handlingStrategy":"validation","validationCode":"if (value == null) throw new IllegalArgumentException(name + \" must not be null\");\n// run before invoking the Druid API","typeGuard":"static <T> T requireNonNull(T val, String name) {\n  if (val == null) throw new IllegalArgumentException(name + \" must not be null\");\n  return val;\n}","tryCatchPattern":"try { druidApi(input); } catch (DruidException e) {\n  if (e.getCategory() == DruidException.Category.INVALID_INPUT) {\n    log.error(\"rejected input: {}\", e.getMessage()); // fix and retry with corrected input\n  }\n  throw e;\n}","preventionTips":["Null-check and format-check all arguments before calling Druid APIs.","Validate spec JSON against the documented schema for your Druid version.","Watch for typos/casing in spec field names that silently leave required fields null.","Surface the dynamic message to users since InvalidInput targets the user persona."],"tags":["invalid-input","argument-validation","druid-exception"],"backgroundTag":"invalid-argument-value","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"}