Skip to content

pass: the Payload carriers checkEncodingKeys walks are hand-listed with no drift guard #303

Description

@OmarAlJarrah

Summary

checkEncodingKeys (pass/validate.go) resolves Content.Encoding keys against the model each content is typed by. To reach every content it names the Payload-bearing fields by hand — Operation.Request, Response.Payload and Message.Payload — and its doc comment says so:

The fields that carry a Payload are named here — Operation.Request, Response.Payload and Message.Payload — so a new one has to be added by hand.

The test side states the same obligation in encodingCarriers() (pass/validate_encoding_test.go): "so one added to the IR has to appear here as well as there". Both lists are hand-written and nothing enforces either. A fourth field carrying an ir.Payload would be walked by neither, and no test would fail: its encoding keys would go unresolved, and an emitter rendering multipart parts from them would silently render no part for a key that misses.

Why this one is unusual

Every other hand-maintained list in the verification layer is held by a reflection-driven drift guard:

  • ir/irverify/indices.go names struct fields by string (FieldByName("Servers")) and is held by indexCarrierFields / integerFields, with TestIntegerFields_AreAllClassified walking the IR by reflection and failing on any unclassified integer field.
  • walkChecks() is held by walkchecks_test.go.
  • ir/nofloat_test.go derives the TypeKind set from the production sources rather than listing it.

grep -n reflect pass/*_test.go finds no completeness assertion over Payload-bearing fields — only the prose obligation. This is the one member of the family with a stated obligation and no guard.

Expected

A reflection-driven test in pass that enumerates the fields whose type is (or contains) ir.Payload reachable from ir.Document, and fails when one is absent from the carrier list checkEncodingKeys walks — the shape indices_test.go already uses for integer-index carriers.

Found while adding checks in pass/validate.go; filed rather than folded into that change.

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