{"record":{"id":"a7c360a120875d19","repo":"apple/pkl","slug":"no-source-modules-specified","errorCode":null,"errorMessage":"No source modules specified.","messagePattern":"No source modules specified\\.","errorType":"validation","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"pkl-gradle/src/main/java/org/pkl/gradle/task/ModulesTask.java","lineNumber":137,"sourceCode":"  private Pair<List<File>, List<URI>> splitFilesAndUris(List<Object> modules) {\n    var files = new ArrayList<File>();\n    var uris = new ArrayList<URI>();\n    for (var m : modules) {\n      var parsed = PluginUtils.parseModuleNotation(m);\n      if (parsed instanceof File file) {\n        files.add(file);\n      } else if (parsed instanceof URI uri) {\n        uris.add(uri);\n      }\n    }\n    return Pair.of(files, uris);\n  }\n\n  @TaskAction\n  @Override\n  public void runTask() {\n    if (getCliBaseOptions().getNormalizedSourceModules().isEmpty()) {\n      throw new InvalidUserDataException(\"No source modules specified.\");\n    }\n    withFallbackTruffleRuntime(this::doRunTask);\n  }\n\n  @Internal\n  @Override\n  // See BasePklTask.getCliBaseOptions() for why caching is intentionally omitted.\n  protected CliBaseOptions getCliBaseOptions() {\n    return new CliBaseOptions(\n        getSourceModulesAsUris(),\n        patternsFromStrings(getAllowedModules().get()),\n        patternsFromStrings(getAllowedResources().get()),\n        getEnvironmentVariables().get(),\n        getExternalProperties().get(),\n        parseModulePath(),\n        getWorkingDir().get().getAsFile().toPath(),\n        mapAndGetOrNull(getEvalRootDirPath(), Paths::get),\n        mapAndGetOrNull(getSettingsModule(), PluginUtils::parseModuleNotationToUri),","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-gradle/src/main/java/org/pkl/gradle/task/ModulesTask.java#L119-L155","documentation":"ModulesTask (base for module-consuming Pkl Gradle tasks) requires at least one source module via the cliBaseOptions sourceModules property. When none are configured, runTask throws InvalidUserDataException with \"No source modules specified.\" instead of invoking the Pkl CLI with an empty module list.","triggerScenarios":"Running a pkl ModulesTask (e.g. pkl test/eval/analyze style tasks) with `sourceModules` left empty in the task or extension configuration, or configuring it only in a different subproject.","commonSituations":"Forgetting to set sourceModules in build.gradle.kts; specifying modules under the wrong extension/task name; applying the plugin but never wiring the module paths; CI running the task before configuration is committed.","solutions":["Configure sourceModules on the task/extension, e.g. `sourceModules = listOf(\"dir/pkl.yaml\", \"...\")` in the pkl block or task config.","Point it at project files like pkl.yaml or .pkl module paths that exist.","Check you configured the correct task/subproject that is actually failing.","If no modules are intended, skip or disable the task (onlyIf / -x) instead of running it empty."],"exampleFix":"// before\npkl { }\n// after\npkl { sourceModules = listOf(\"pkl.yaml\", \"gen/pkl.yaml\") }","handlingStrategy":"validation","validationCode":"val modules = pklExtension.sourceModules.orEmpty()\nrequire(modules.isNotEmpty()) { \"Configure pkl.sourceModules before running ${tasks.withType<ModulesTask>().map { it.name }}\" }","typeGuard":"fun ModulesTask.hasModules() = cliBaseOptions.normalizedSourceModules.isNotEmpty()","tryCatchPattern":"try { runTask() } catch (InvalidUserDataException e) { if (e.message == \"No source modules specified.\") logger.error(\"Add sourceModules to the pkl block\"); throw e }","preventionTips":["Define sourceModules in a shared convention plugin for all subprojects","List module paths (pkl.yaml / .pkl) explicitly in build.gradle.kts","Add a Gradle check that fails fast on empty module lists","Skip module tasks via onlyIf when nothing is configured"],"tags":["gradle","pkl","missing-argument","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}