Skip to content

HTTP codegen mishandles OneOf when used with ResultType views #3916

@sevein

Description

@sevein

Goa HTTP codegen generates inconsistent transport code when a design combines:

  • a request body that uses OneOf(...)
  • a ResultType that also uses OneOf(...)
  • viewed/projected results

In that situation, the generated packages can fail to build because different codegen paths disagree about the effective transport shape.

Observed failures include:

  • gen/http/{service}/client/cli.go references missing Validate*RequestBody helpers for OneOf request members
  • generated client/server response unions reference branch body types that are not emitted
  • viewed response bodies are projected in some places but not others, so generated client decode/init code still refers to fields removed by the selected view

Minimal repros:

  • oneof_resulttype_client_bug:
    Client CLI references missing Validate*RequestBody helpers for OneOf request-body members.
  • oneof_direct_result_bug:
    Direct ResultType response generates a union whose response branch body types are never emitted.
  • oneof_result_projection_bug:
    Projected/viewed responses mix projected and unprojected OneOf shapes, producing stale type references across client/server HTTP codegen.

Note: gpt-5.4-high came up with a fix (sevein@1e5c84e), in case it saves you some time. The fix seems to address the problem seen in the minimal repros above (sevein/examples@180abb3).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions