{"record":{"id":"01d419f76c0e9176","repo":"apache/druid","slug":"a-local-input-source-can-set-parameter-s-or-s-b","errorCode":null,"errorMessage":"A local input source can set parameter %s or %s, but not both.","messagePattern":"A local input source can set parameter (.+?) or (.+?), but not both\\.","errorType":"validation","errorClass":"IAE","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/table/LocalInputSourceDefn.java","lineNumber":141,"sourceCode":"  {\n    jsonMap.put(InputSource.TYPE_PROPERTY, LocalInputSource.TYPE_KEY);\n\n    final String baseDirParam = CatalogUtils.getString(args, BASE_DIR_PARAMETER);\n    final List<String> filesParam = CatalogUtils.getStringArray(args, FILES_PARAMETER);\n    final String filterParam = CatalogUtils.getString(args, FILTER_PARAMETER);\n    final boolean hasBaseDir = !Strings.isNullOrEmpty(baseDirParam);\n    final boolean hasFiles = !CollectionUtils.isNullOrEmpty(filesParam);\n    final boolean hasFilter = !Strings.isNullOrEmpty(filterParam);\n    if (!hasBaseDir && !hasFiles) {\n      throw new IAE(\n          \"A local input source requires one parameter of %s or %s\",\n          BASE_DIR_PARAMETER,\n          FILES_PARAMETER\n      );\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      );","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/table/LocalInputSourceDefn.java#L123-L159","documentation":"When the local input source table function receives both baseDir and files, the Druid LocalInputSource itself cannot represent both at once, so the catalog resolves the combination by converting files to paths relative to baseDir. That workaround is only safe when no filter is also given, since a filter plus an explicit file list is contradictory. Supplying baseDir + files + filter therefore throws this IAE.","triggerScenarios":"Calling the local input source table function with all three parameters: baseDir, files, and filter all non-empty.","commonSituations":"Users copying a template that had baseDir+filter and adding a files argument; tools generating arguments that always emit filter; misunderstanding that files already selects files so a filter is redundant.","solutions":["Remove the filter parameter when files is provided","Remove files and keep baseDir + filter to select files by pattern","If files need a base directory prefix, pass absolute paths in files without baseDir"],"exampleFix":"// before\nTABLE('local', BASE_DIR => '/data', FILES => ARRAY['a.json'], FILTER => '*.json')\n// after\nTABLE('local', BASE_DIR => '/data', FILES => ARRAY['a.json'])","handlingStrategy":"validation","validationCode":"// Java\nif (hasParam(args,\"baseDir\") && hasParam(args,\"files\") && hasParam(args,\"filter\"))\n  throw new IllegalArgumentException(\"Use files OR filter with baseDir, not both\");","typeGuard":null,"tryCatchPattern":"try { fn.call(args); } catch (IAE e) { if (e.getMessage().contains(\"but not both\")) { args.remove(\"filter\"); fn.call(args); } else throw e; }","preventionTips":["Never combine files with filter — files is already an explicit selection","Decide upfront: file list (files) or pattern search (baseDir+filter)","Audit generated SQL/args templates for all-three combinations"],"tags":["druid-catalog","validation","mutually-exclusive","table-function"],"backgroundTag":"mutually-exclusive-options","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"}