Skip to content

ResponseStreamEvent: Codable conformance is asymmetric #427

Description

@nezhyborets

ResponseStreamEvent conforms to Codable, but the conformance is asymmetric:

  • init(from:) is custom — it decodes from the API's top-level type discriminator format.
  • encode(to:) is synthesized — it encodes using Swift enum case wrappers, which don't match the API payload shape.

This means encoding an event and decoding it back will fail, which can surprise callers who try to log, cache, or replay events via JSON.

Options:

  1. Implement a matching encode(to:) that encodes the underlying event payloads in the original API shape.
  2. Drop Encodable conformance and use Decodable only, if encoding isn't intended.

Flagged by Copilot review on #423.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions