-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocumented duplicate key behaviour for events and rules #22
Comments
Here's what I believe:
#2 because that's what the software does now and if you change it you'll probably break at least one relying service, which means it has become part of your contract per Hyrum's law: https://www.hyrumslaw.com |
Still digging into this one but (1) might be an issue if clients are not checking for duplicate keys in rules similar to |
Proposal for this issue 1/ Add a caveat that Ruler's current APIs follow the default jackson behaviour for deserializting. This means we'll only consider the final value in the document order. Maybe a final note that this is subject to change in future. This avoids breaking any clients today, and lets them migrate in future. Not expecting any performance hits as we create a parse during rule-compilation https://github.com/aws/event-ruler/blob/main/src/main/software/amazon/event/ruler/JsonRuleCompiler.java#L118 |
It may be a bit more complex than that. Ruler has multiple APIs with different approaches. In at least one place it uses Jackson My proposal would be to figure out what it does and document that. I would say that we should reject |
agree with Tim, we shall ensure to reject the duplicated filed name for none array situation, we can enforce our API to allow
but reject below
|
oh, please ignore my previous reply, I had thought it is for event, I mean for even, we can enforce above what I mentioned.
|
Looks like when we aren't using ObjectMapper, we use JsonParser. Just like ObjectMapper, there's a way to configure the parser to enforce STRICT_DUPLICATE_DETECTION. We definitely can't change the exiting parser / object-mapper (as it'll break existing users) but just like customers have the option to pass a parsed JSONNode for events (and perform any validation on their side before making the call), wondering if its reasonable to allow customers to pass JsonNode / JsonParser to us for rules as well. It'll mean adding more Along with it, I like the idea of adding new methods that enforce stricting cheking by default but I think we'll need a different name than |
thinking more on this, one more option we have is make GenericMachine configurable during construction and allow whichever JSON parsing preferences customers would want via the constructor. We can then tweak our internal mappers / parsers based on their preferences. It'll mean a new constructor, but no new addRule / deleteRule for folks to migrate to (and fewer methods for us to manage keep around). |
So, have a |
Yes. I need to check which of the two will be easier for customers to adopt. I suspecting |
…iour This minor change is related to #22. Would like to make sure there's at least something in the document on the expected behaviour. In future, this section can be updated with recommendation to move to better APIs.
…iour This minor change is related to #22. Would like to make sure there's at least something in the document on the expected behaviour. In future, this section can be updated with recommendation to move to better APIs. Also updating the pom.xml to make it easier to release changes. Going forward, we'll enforce version bumps for key changes.
Describe the bug
High level description of the issue is we can create duplicate keys in our rules and the library will only use the last duplicate in the rule
For example if this is my rule:
A customer may expect it to capture both detail S3 and SNS events from CloudTrail. But it turns out we only trigger only the second key (which in this case is SNS).
This is within the bounds of the JSON spec https://datatracker.ietf.org/doc/html/rfc8259#section-4
Still, it's better if we 1/ handle it for users when de-serializing via ObjectMapper[1] and 2/ document this edge case if they are passing the JSONNode to us.
[1] FasterXML/jackson-databind#237 shows that we can use
DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY
The text was updated successfully, but these errors were encountered: