OpenAPITools/openapi-generator · error · RuntimeException
inputSpecFiles list is empty — nothing to merge
Error message
inputSpecFiles list is empty — nothing to merge
What it means
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.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/config/MergedSpecBuilder.java:171
* definition (default), or {@link MergeConflictStrategy#FAIL} to throw a
* {@link RuntimeException} and abort.
* @return this builder, for chaining
*/
public MergedSpecBuilder withConflictStrategy(MergeConflictStrategy strategy) {
this.conflictStrategy = strategy;
return this;
}
public String buildMergedSpec() {
if (inputSpecFiles != null) {
return buildMergedSpecFromList();
}
return buildMergedSpecFromDirectory();
}
private String buildMergedSpecFromList() {
if (inputSpecFiles.isEmpty()) {
throw new RuntimeException("inputSpecFiles list is empty — nothing to merge");
}
deleteMergedFileFromPreviousRun();
LOGGER.info("Merging {} explicit spec files into {}", inputSpecFiles.size(), outputDirectory);
return buildMergedSpec(inputSpecFiles, outputDirectory);
}
private String buildMergedSpecFromDirectory() {
deleteMergedFileFromPreviousRun();
List<String> specRelatedPaths = getAllSpecFilesInDirectory();
if (specRelatedPaths.isEmpty()) {
throw new RuntimeException("Spec directory doesn't contain any specification");
}
LOGGER.info("In spec root directory {} found specs {}", inputSpecRootDirectory, specRelatedPaths);
// Resolve relative paths to absolute so the shared build logic works uniformly
List<String> absolutePaths = specRelatedPaths.stream()
.map(rel -> Paths.get(inputSpecRootDirectory, rel).toAbsolutePath().toString())
.collect(Collectors.toList());
return buildMergedSpec(absolutePaths, inputSpecRootDirectory);View on GitHub (pinned to fcec517be3)
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.
Example fix
// before
builder.setInputSpecFiles(new ArrayList<>());
// after
List<String> specs = Arrays.asList("pet.yaml", "store.yaml");
if (!specs.isEmpty()) builder.setInputSpecFiles(specs); else throw new IllegalStateException("no specs discovered"); Defensive patterns
Strategy: validation
Validate before calling
if (inputSpecFiles != null && inputSpecFiles.isEmpty()) {
throw new IllegalStateException("inputSpecFiles configured but empty — populate it or use directory mode");
} Try / catch
Catch RuntimeException from buildMergedSpec() when the message contains "nothing to merge"; treat as configuration error, check discovery step, no retry.
Prevention
- Fail your glob/discovery step loudly on zero matches instead of passing an empty list on.
- Log the resolved spec list size before merging.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Malformed OpenAPI version '%s' in a source spec. Expected ex
- %s Input: `%s`. Error: %s
- filter with no value not supported :[{filter}]
- Couldn't load template engine adapter %s. Available options:
- Spec directory doesn't contain any specification
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/6a3be6cecfd2a8bf.
Report an issue: GitHub.