{"record":{"id":"b086dc2778d9b860","repo":"apache/druid","slug":"s-dynamic-msg-passed-to-invalidinput-exception-w","errorCode":null,"errorMessage":"%s (dynamic msg passed to InvalidInput.exception with cause)","messagePattern":"(.+?) \\(dynamic msg passed to InvalidInput\\.exception with cause\\)","errorType":"validation","errorClass":"DruidException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/error/InvalidInput.java","lineNumber":72,"sourceCode":"  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\n  public static void conditionalException(boolean condition, Throwable t, String msg, Object... args)\n  {\n    if (!condition) {\n      throw exception(t, msg, args);\n    }\n  }\n\n\n  public InvalidInput(\n      Throwable t,\n      String msg,\n      Object... args\n  )\n  {\n    super(\n        \"invalidInput\",\n        DruidException.Persona.USER,\n        DruidException.Category.INVALID_INPUT,\n        t, msg, args\n    );\n  }\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/error/InvalidInput.java#L54-L90","documentation":"This is Druid's InvalidInput exception raised via the conditionalException helper in processing/src/main/java/org/apache/druid/error/InvalidInput.java. When the boolean condition is false, the supplied message (formatted with args) is wrapped in an InvalidInput exception along with the given cause. It signals caller-supplied input that violates an API precondition, and the actual message text is dynamic, supplied by each call site.","triggerScenarios":"Any call to ApiPredicate/InvalidInput.conditionalException(condition, t, msg, args) where the condition evaluates to false; the dynamic msg text identifies the violated precondition at that specific call site.","commonSituations":"Query/ingestion API handlers validating user-supplied parameters (datasource names, intervals, filters); malformed REST request bodies; programmatic API misuse passing nulls or out-of-range values.","solutions":["Read the dynamic message in the exception text to identify which precondition failed and which parameter was rejected.","Correct the offending input parameter at the call site per the message.","Inspect the attached cause (Throwable t) for the underlying reason.","If you own the call site, ensure the condition check matches documented API constraints."],"exampleFix":"// before\nconditionalException(!isValidDatasource(name), t, \"invalid datasource %s\", name);\n// after\n// validate/normalize input first\nString validated = normalizeDatasource(name);\nconditionalException(!isValidDatasource(validated), t, \"invalid datasource %s\", validated);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["input-validation","druid","api"],"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"}