{"record":{"id":"7150ab9830a64447","repo":"apple/pkl","slug":"sourcemodules-must-contain-at-least-one-module-t","errorCode":null,"errorMessage":"`sourceModules` must contain at least one module to generate documentation for.","messagePattern":"`sourceModules` must contain at least one module to generate documentation for\\.","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt","lineNumber":203,"sourceCode":"        else -> regularModuleUris.add(moduleUri)\n      }\n    }\n\n    if (docsiteInfoModuleUris.size > 1) {\n      throw CliException(\n        \"`sourceModules` contains multiple modules named `docsite-info.pkl`:\\n\" +\n          docsiteInfoModuleUris.joinToString(\"\\n\")\n      )\n    }\n\n    if (packageInfoModuleUris.isEmpty() && packageUris.isEmpty()) {\n      throw CliException(\n        \"`sourceModules` must contain at least one module named `doc-package-info.pkl`, or an argument must be a package URI.\"\n      )\n    }\n\n    if (regularModuleUris.isEmpty() && packageUris.isEmpty()) {\n      throw CliException(\n        \"`sourceModules` must contain at least one module to generate documentation for.\"\n      )\n    }\n\n    val builder = evaluatorBuilder()\n    var docsiteInfo: DocsiteInfo\n    val schemasByDocPackageInfoAndPath =\n      mutableMapOf<Pair<DocPackageInfo, Path>, MutableSet<ModuleSchema>>()\n    val schemasByDocPackageInfo = mutableMapOf<DocPackageInfo, Set<ModuleSchema>>()\n    // Evaluate module imports eagerly, which is cheap if docs are also generated for most imported\n    // modules.\n    // Alternatively, imports could be evaluated lazily,\n    // at the expense of interleaving schema/module evaluation and Pkldoc generation.\n    val importedModules: MutableMap<URI, ModuleSchema> = mutableMapOf()\n\n    try {\n      fun Evaluator.collectImportedModules(imports: Map<String, URI>) {\n        for ((_, uri) in imports) {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-doc/src/main/kotlin/org/pkl/doc/CliDocGenerator.kt#L185-L221","documentation":"pkl-doc throws when there is nothing to document: `sourceModules` contains no regular modules and no package URIs were given. The generator has no modules to produce documentation for, so it fails fast before building the evaluator.","triggerScenarios":"Running `pkl-doc` with only a `docsite-info.pkl` (or doc-package-info) module as sourceModules and zero regular modules and zero package URI arguments.","commonSituations":"Empty or misconfigured CI command; glob pattern in a script matched no files so only the info module remained; intending to pass packages but forgetting the package URI arguments.","solutions":["Add at least one regular module or package URI argument to the command","Verify any glob/script variable expanding to module paths is non-empty","Check the command in CI logs — the arguments may have been dropped by quoting"],"exampleFix":"// before\npkl-doc docsite-info.pkl\n// after\npkl-doc docsite-info.pkl com/example/pkg/Module.pkl","handlingStrategy":"validation","validationCode":"val docTargets = sourceModules.filter { it.fileName !in setOf(\"docsite-info.pkl\", \"doc-package-info.pkl\") } + packageUris\nrequire(docTargets.isNotEmpty()) { \"No modules or packages to document\" }","typeGuard":null,"tryCatchPattern":"try { pklDoc(args) } catch (e: CliException) { if (e.message?.contains(\"at least one module to generate documentation\") == true) { /* fix empty arg list */ } else throw e }","preventionTips":["Assert the resolved module list is non-empty before invoking pkl-doc in scripts","Quote globs properly in shell so they expand as intended","Log the final command line in CI for debugging"],"tags":["cli","empty-input","validation"],"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"}