Skip to content

Open unions: tagged unions keep the whole object even if extra keys are present #1713

@kubukoz

Description

@kubukoz

To reproduce:

$version: "2"

namespace demo

use alloy#jsonUnknown

union MyOpenUnion {
  s1: Unit
  s2: Unit
  @jsonUnknown other: Document
}

Read this:

{"a": 42, "b": "oops"}

it'll all be persisted in the Document. I believe the behavior should be to fail decoding due to multiple root keys.

You can try it out in Smithy Transcoder: https://kubukoz.github.io/smithy-transcoder/#N4Igtg9gJgpgNgFRgDwC4gFwgCQDcYBOAzgJYQB2GABADogBMdN5z5AhmDEQA5sDGMKrEjNmAVyKC2cOBACeAYgBWRCgFVyAa3IQA7iwNjyZclQCycgPLcY5DSarBmVKkQCM1e6mev6n496mVAACKupaOvpUEKgAFoTUACIQfGKc5IEAviAANCAAZhAEYGzoGKBh5Jig+STwUABiJHCohJggiQCiDQCCagAyCCCZmXkk5NxiZSBOIGx01AAs9Dm0IABGC2sQENxEdNl5+MQmmG6ZQA

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