Skip to content

[Bug]: SchemaValidator.validateFixCoverageInternal() uses orElse(0) without empty check #177

@Splatcrafter

Description

@Splatcrafter

AI REVIEWED

Module: schema-tools
File: schematools/validation/SchemaValidator.java (~line 381-453)
Severity: Low

Summary

final int minVersion = schemas.stream()
    .map(s -> s.version().getVersion())
    .min(Comparator.naturalOrder())
    .orElse(0);

If the registry is empty after bootstrap, orElse(0) assumes version 0 exists. This could create invalid analysis parameters without any schema data to analyze.

Expected Behavior

Return early with an empty/valid result if no schemas exist.

Suggested Fix

if (schemas.isEmpty()) {
    return ValidationResult.empty();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions