Skip to content

Emtemf/api-codegen REV-2026-010: Return structured validation errors for null and nested API fields #16

Description

@Emtemf

finding_id: REV-2026-010
priority: P1
area: validator
kind: bug
paths:

  • api-codegen-core/src/main/java/com/apicgen/validator/ApiValidator.java
  • api-codegen-core/src/main/java/com/apicgen/validator/ValidationAnalyzer.java
  • api-codegen-core/src/main/java/com/apicgen/bridge/UiDocumentService.java
    blocked_by: []
    automation: needs-design

Summary

Return structured validation errors for null and nested API fields instead of throwing or misclassifying internal failures as YAML syntax errors.

Evidence

Global review finding REV-2026-010 identified null elements such as apis:[null] and fields:[null], insufficient nested-field validation, and bridge error mapping that can mask internal NPEs.

Impact

Malformed documents can crash validation, lose the failing index/path, or produce misleading UI diagnostics; valid callers cannot rely on a stable result contract.

Scope

Add indexed ValidationError results for null and nested malformed values, preserve immutable validation snapshots, and distinguish model/validation failures from YAML parse failures in the bridge.

Out of scope

Changing accepted Swagger/OpenAPI dialects, parser security limits, or unrelated generator diagnostics.

Acceptance criteria

  • apis:[null]fields:[null] 返回带索引的 ValidationError,不抛 NPE
  • nested fields 递归校验 name/type/validation
  • bridge 不把内部 NPE 伪装成 YAML 语法错误
  • ValidationResult 返回不可变快照
  • 增加 null/nested malformed fixture

Verification

Run validator and bridge tests with null, nested malformed, parse-invalid, and valid fixtures; assert error types, indexes, paths, and immutable result behavior.

Rollback

Revert the validation-contract implementation while retaining malformed fixtures and documenting compatibility constraints discovered.

Dependencies

None. Keep this issue labeled automation:needs-design; do not add automation:ready until design review is complete.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions