Skip to content

Add YAML emission value policy controls #64

Description

Context

YAML dumping and presentation can omit or include values according to application policy. PowerShell users often need to omit nulls or defaults, suppress aliases for consumer compatibility, or emit explicit tags for clarity.

Official YAML 1.2.2 references:

Current State

The emitter serializes supported values deterministically and uses anchors/aliases for repeated acyclic collection references. There are no public options for omitting null/default values, suppressing aliases, or forcing explicit tag emission.

Objective

Add explicit value-policy controls for emission while preventing silent loss unless the caller requested that policy.

PowerShell Design Considerations

  • Value policy options should be explicit switches or validated parameters with clear semantics.
  • Parameter sets should prevent incompatible combinations where one policy makes another meaningless or unsafe.
  • Omission should work naturally for rich PowerShell objects, dictionaries, and pipeline records without depending on implementation-specific object internals.
  • Alias suppression should be safe: if suppressing aliases would misrepresent shared or cyclic graphs, it must fail or require a clearly documented policy.

Tasks

  • Add opt-in null omission behavior.
  • Add opt-in default-value omission behavior for supported object shapes.
  • Add opt-in alias suppression behavior with cycle and shared-reference safety.
  • Add explicit tag emission behavior for supported scalar and collection values.
  • Document how policies apply to dictionaries, objects, arrays, and multiple pipeline records.

Benefits

  • Supports common configuration-file emission patterns.
  • Makes loss-inducing output policies explicit and testable.
  • Improves interoperability with consumers that cannot handle YAML aliases or implicit tags.

Acceptance Criteria

  • Nulls are omitted only when the caller requests null omission.
  • Default values are omitted only when the caller requests default omission and defaults can be determined safely.
  • Alias suppression does not silently corrupt shared or cyclic graphs.
  • Explicit tag emission produces parseable YAML with the intended effective tags.
  • Unsupported combinations produce classified errors before writing output.

Related

  • Spec folder: spec/Emission-Value-Policy.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions