Skip to content

compilers/openapi: a failed raw conversion preserves nothing while its diagnostic claims otherwise #144

Description

@OmarAlJarrah

Every preserve + announce pair in the compiler emits a diagnostic stating that a construct was
"kept verbatim under Unmodeled", then writes the entry. When the raw conversion fails, the write
silently records nothing and the diagnostic still claims the construct survived.

nodeToRaw fails on a YAML mapping whose keys are not strings — legal YAML, and reachable in a
vendor extension or inside a preserved validation-only keyword:

x-weird:
  ? [a, b]
  : value

The result is a diagnostic asserting preservation with no entry behind it, which is worse than
either outcome alone: a consumer that trusts the diagnostic looks for a key that is not there,
and a consumer auditing losslessness sees a clean report.

Scope

This is file-wide rather than one site — preserveUnionSiblings, the path-servers site, the
error-headers site, the requestBody-optionality site and the allOf-branch residue site all share
the shape. The honest fix is a shared guard across every preserve-and-announce pair: either the
entry is written and the diagnostic fires, or neither happens and a different diagnostic reports
that the construct could not be represented at all.

Worth deciding at the same time whether an unrepresentable construct is an error rather than
an info — it is a genuine losslessness failure, not a degradation.

Method

Found while adding the allOf-branch residue path, by reading the existing preserve idiom rather
than by probe; the failure mode follows from nodeToRaw returning an error that the callers do
not branch on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions