question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How should a server reject unknown union variants?

See original GitHub issue

Since enum is a constraint trait, if a server encounters an unknown enum variant, it should reject the request just like it would fail to constrain any other value for a constrained shape: that is, the server should parse the request successfully and then constrain the resulting value, returning a collection of constraint violations, if any. In the case of an unknown enum variant, one of those errors should convey that there was an unknown enum variant. Here is one protocol test in the validation suite enforcing this behavior:

https://github.com/awslabs/smithy/blob/1863d672dde488ccd81d9c00c64f57a26728f75d/smithy-aws-protocol-tests/model/restJson1/validation/malformed-enum.smithy#L17-L49

(Aside: it would be nice if the spec on constraint traits documented this server behavior instead of using the protocol tests as a normative reference).


My question is what should happen if a server encounters unknown union variants. It is not obvious, since a union is a shape itself and not a constraint trait like enum. If a server is parsing a union, it will first read the tag and match it against the known modeled tags. If it encounters an unknown tag, should it then:

  1. Immediately reject the request with a deserialization failure; or
  2. Store the unknown tag, discard the union’s value (since it can’t know its structure), parse the rest of the request successfuly, and insert some sort of validation error in the response, just like we should do for constraint traits?

I think the answer should be (1); it’d be nice if a test could be added to malformed-union.smithy and the spec could call this out if so.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mtdowlingcommented, Sep 8, 2022

Hm, no, enums are still open types. There’s effectively no behavioral change, just a modeling change.

0reactions
david-perezcommented, Sep 8, 2022

I’m guessing set shapes in IDL v1 should be rejected in the case of duplicate items in the same way as list shapes with uniqueItems in IDL v2 then: the request is parsed entirely and only then the check is performed. So, another modeling change, but no behavioral change in this regard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Injection Cheat Sheet - Invicti
The SQL Injection Cheat Sheet is the definitive resource for all the technical details about the different variants of the well-known SQLi vulnerability....
Read more >
Selecting variants of unknown significance through network ...
Variants of unknown/uncertain significance (VUS) pose a huge dilemma in current genetic variation screening methods and genetic counselling.
Read more >
How do I blacklist and reject an email server based on ... - Cisco
This document describes how to blacklist and reject an email server based on the geolocation using Sender Group on the Email Security ...
Read more >
Union Your Data - Tableau Help
Supported connectors may vary between Tableau Desktop and Tableau Server and Tableau Cloud. For best results, the tables that you combine using a...
Read more >
The Transport Layer Security (TLS) Protocol Version 1.2
The protocol allows client/server applications to communicate in a way that ... but they are significant enough that the various versions of TLS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found