Skip to content

Incorrect enforcement of the length trait when applied to string shapes #509

@david-perez

Description

@david-perez

As far as I can see, the code is enforcing Smithy's length constraint trait as a call to the JavaScript's object length property.

This implementation is wrong for JavaScript Strings, because its length property counts the number of UTF-16 code units, but the Smithy spec says length counts the number of Unicode code points when applied to strings.

These are not the same; consider characters outside the basic multilingual plane. U+10000 is encoded using two UTF-16 code units, but is only one Unicode code point (scalar value).

This would have been caught with Smithy protocol tests: smithy-lang/smithy#1090.

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