Skip to content

Discrepancy of null handling when a default is present or not #1581

@kubukoz

Description

@kubukoz

Compare the following:

structure Person {
  item: String = null
}

structure Person2 {
  item: String
}

structure Person3 {
  item: String = ""
}

Given a payload like {"item": null}, only Person2 will be decoded successfully if you're using generated code.

Noteworthy:

  • Dynamic will accept the input in all cases, but only Person3 will have a field present with the default value. The others will simply not have that field.

Full repro: https://github.com/kubukoz/demos/tree/smithy4s-nulls-defaults (sbt run shows you all the results)

There's surely a bug here because Dynamic and Codegen don't work the same way, but which should it be? I'm leaning towards thinking that = null should be equivalent to nothing (see #1315), and I'm pretty sure all these cases should accept the input somehow.

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