{"record":{"id":"6a3be6cecfd2a8bf","repo":"OpenAPITools/openapi-generator","slug":"inputspecfiles-list-is-empty-nothing-to-merge","errorCode":null,"errorMessage":"inputSpecFiles list is empty — nothing to merge","messagePattern":"inputSpecFiles list is empty — nothing to merge","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/config/MergedSpecBuilder.java","lineNumber":171,"sourceCode":"     *                 definition (default), or {@link MergeConflictStrategy#FAIL} to throw a\n     *                 {@link RuntimeException} and abort.\n     * @return this builder, for chaining\n     */\n    public MergedSpecBuilder withConflictStrategy(MergeConflictStrategy strategy) {\n        this.conflictStrategy = strategy;\n        return this;\n    }\n\n    public String buildMergedSpec() {\n        if (inputSpecFiles != null) {\n            return buildMergedSpecFromList();\n        }\n        return buildMergedSpecFromDirectory();\n    }\n\n    private String buildMergedSpecFromList() {\n        if (inputSpecFiles.isEmpty()) {\n            throw new RuntimeException(\"inputSpecFiles list is empty — nothing to merge\");\n        }\n        deleteMergedFileFromPreviousRun();\n        LOGGER.info(\"Merging {} explicit spec files into {}\", inputSpecFiles.size(), outputDirectory);\n        return buildMergedSpec(inputSpecFiles, outputDirectory);\n    }\n\n    private String buildMergedSpecFromDirectory() {\n        deleteMergedFileFromPreviousRun();\n        List<String> specRelatedPaths = getAllSpecFilesInDirectory();\n        if (specRelatedPaths.isEmpty()) {\n            throw new RuntimeException(\"Spec directory doesn't contain any specification\");\n        }\n        LOGGER.info(\"In spec root directory {} found specs {}\", inputSpecRootDirectory, specRelatedPaths);\n        // Resolve relative paths to absolute so the shared build logic works uniformly\n        List<String> absolutePaths = specRelatedPaths.stream()\n                .map(rel -> Paths.get(inputSpecRootDirectory, rel).toAbsolutePath().toString())\n                .collect(Collectors.toList());\n        return buildMergedSpec(absolutePaths, inputSpecRootDirectory);","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/MergedSpecBuilder.java#L153-L189","documentation":"MergedSpecBuilder.buildMergedSpecFromList() runs when inputSpecFiles was set (list mode) and throws if that list is empty. The builder was explicitly configured for list-mode merging (inputSpecFiles non-null) yet contains nothing to merge, which is treated as a caller error rather than falling back to directory mode. This guards against silently producing no output.","triggerScenarios":"Calling the merge API / --input-spec-catalog or MergedSpecBuilder.setInputSpecFiles(...) with an empty list, or a pipeline variable that evaluates to empty; inputSpecFiles= new ArrayList<>() with no additions.","commonSituations":"Glob expressions matching zero files feeding the list (e.g. buildMergedSpec input '*.yaml' in an empty dir); CLI/maven configurations where the list property is declared but never populated; CI matrices generating per-module specs where one module has none.","solutions":["Populate inputSpecFiles with at least one valid spec file path before calling buildMergedSpec().","Fix the glob/discovery step that produced the empty list (check directory, pattern, working directory).","If merging is optional in your flow, skip calling the builder when the list is empty.","Prefer directory mode (set inputSpecRootDirectory instead) when the file set is dynamic."],"exampleFix":"// before\nbuilder.setInputSpecFiles(new ArrayList<>());\n// after\nList<String> specs = Arrays.asList(\"pet.yaml\", \"store.yaml\");\nif (!specs.isEmpty()) builder.setInputSpecFiles(specs); else throw new IllegalStateException(\"no specs discovered\");","handlingStrategy":"validation","validationCode":"if (inputSpecFiles != null && inputSpecFiles.isEmpty()) {\n    throw new IllegalStateException(\"inputSpecFiles configured but empty — populate it or use directory mode\");\n}","typeGuard":null,"tryCatchPattern":"Catch RuntimeException from buildMergedSpec() when the message contains \"nothing to merge\"; treat as configuration error, check discovery step, no retry.","preventionTips":["Fail your glob/discovery step loudly on zero matches instead of passing an empty list on.","Log the resolved spec list size before merging."],"tags":["openapi","spec-merge","configuration","empty-input"],"backgroundTag":"empty-input-list","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}