{"record":{"id":"0e747a6fa6382c99","repo":"apache/druid","slug":"if-a-local-input-source-sets-parameter-s-it-must","errorCode":null,"errorMessage":"If a local input source sets parameter %s, it must also set parameter %s","messagePattern":"If a local input source sets parameter (.+?), it must also set parameter (.+?)","errorType":"validation","errorClass":"IAE","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/table/LocalInputSourceDefn.java","lineNumber":155,"sourceCode":"      );\n    }\n    if (hasBaseDir && hasFiles) {\n      if (hasFilter) {\n        throw new IAE(\n            \"A local input source can set parameter %s or %s, but not both.\",\n            FILES_PARAMETER,\n            FILTER_PARAMETER\n        );\n      }\n      // Special workaround: if the user provides a base dir, and files, convert\n      // the files to be absolute paths relative to the base dir. Then, remove\n      // the baseDir, since the Druid input source does not allow both a baseDir\n      // and a list of files.\n      jsonMap.put(FILES_FIELD, absolutePath(baseDirParam, filesParam));\n      return;\n    }\n    if (!hasBaseDir && !Strings.isNullOrEmpty(filterParam)) {\n      throw new IAE(\n          \"If a local input source sets parameter %s, it must also set parameter %s\",\n          FILTER_PARAMETER,\n          BASE_DIR_PARAMETER\n      );\n    }\n    if (hasBaseDir) {\n      jsonMap.put(BASE_DIR_FIELD, baseDirParam);\n    }\n    if (hasFiles) {\n      jsonMap.put(FILES_FIELD, filesParam);\n    }\n    if (filterParam != null) {\n      jsonMap.put(FILTER_FIELD, filterParam);\n    }\n  }\n\n  private List<String> absolutePath(String baseDirPath, List<String> files)\n  {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/table/LocalInputSourceDefn.java#L137-L173","documentation":"A filter parameter for the local input source is interpreted relative to a base directory; without baseDir the filter pattern has no root to search. When the table function call supplies filter but no baseDir (and no files), convertArgsToSourceMap rejects the combination with this IAE.","triggerScenarios":"Calling the local input source table function with filter set but neither baseDir nor files provided (files+filter is rejected earlier at error 1891 if baseDir is also present).","commonSituations":"Assuming filter applies to the server's working directory; switching from baseDir+files+filter to just filter after seeing error 1891 and dropping baseDir too.","solutions":["Add a baseDir parameter alongside filter","Use files with explicit paths instead of filter","If filtering the current working directory is intended, set baseDir explicitly to that directory"],"exampleFix":"// before\nTABLE('local', FILTER => '*.json')\n// after\nTABLE('local', BASE_DIR => '/data', FILTER => '*.json')","handlingStrategy":"validation","validationCode":"// Java\nboolean hasFilter = hasNonEmpty(args.get(\"filter\"));\nboolean hasBaseDir = hasNonEmpty(args.get(\"baseDir\"));\nif (hasFilter && !hasBaseDir) throw new IllegalArgumentException(\"filter requires baseDir\");","typeGuard":null,"tryCatchPattern":"try { fn.call(args); } catch (IAE e) { if (e.getMessage().startsWith(\"If a local input source sets parameter\")) { /* add baseDir or drop filter */ } else throw e; }","preventionTips":["Treat filter and baseDir as an inseparable pair","Never assume filter applies to the server working directory","Validate filter/baseDir pairing in any SQL-generating code"],"tags":["druid-catalog","validation","table-function","local-input-source"],"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"}