-
Notifications
You must be signed in to change notification settings - Fork 749
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
Generic timestamp request #321
Conversation
@JsonDeserialize( | ||
builder = GenericTimestampRequest.Builder.class | ||
) | ||
public class GenericTimestampRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this belongs in the model package. We'd have to create some sort of base class and have RequestEnvelope inherit and extend. The models are autogenerated so we would have to make the change I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is that when you deal with requests that are not present in the model package. I think that request validation should not rely on the model package - you should have anemic request class that should deserialize to fields required only by validation logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to some degree, I think this function should only extract what it needs. But that should be defined as a generic object in the model. Otherwise, we have two packages where a request is defined. i.e however unlikely, if the timestamp field moves/renamed, this would be hard to catch in the future.
so not entirely against this just need to think about this a bit more. Currently I see more pros in having this in the model than cons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the biggest problem here is that I cannot edit your template files since they're private. Also having a base class can be tricky when relying on builders to create objects.
I know that there is a defaultImpl property in Jackson: https://fasterxml.github.io/jackson-annotations/javadoc/2.6/com/fasterxml/jackson/annotation/JsonTypeInfo.html#defaultImpl()
So a request could be mapped to UnknownRequest
that would have locale, type, request-id, and timestamp.
Could you elaborate more about cases where the incoming Alexa Request cannot be Deserialized? |
@doiron We are participating in private beta and we deal with requests that are not present in model package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you kkocel for making this change and improving the experience for others. :)
After syncing with the team we decided not to go ahead with this solution as it does validate that the request is in-fact a RequestEnvelope. This add extra layers of protection and will deny requests that have extra ( potentially malicious ) json parameters. |
In this case, you would need to have the updated SDK that adds the Beta feature support. Otherwise the skill should not be accepting the request. |
There are two types of vaildators in the SDK - one that validates request signature Even if the request has extra json parameters they will be discarded by Jackson deserialization - because Jackson deserializes json into a well defined Java object. Having this knowledge maybe team can reconsider? |
Ok, so I would like to get the thin jar containing model package only for the beta we are participating in. We do not want uber/fat jar since dealing with it is maintainability nightmare. We will pass this request through our solution architect as well. |
Furthermore, this change would need to:
Since this would take a while for us to prioritize and sort out, I've compiled a jar file to unblock you in the interim, let us know how that works out. thanks again for working on this. |
I left an issue for this: #326 |
Description
Instead of using a full request just created an essential request class that has fields that are only needed.
Motivation and Context
When an unknown request type comes to the validator it fails because it cannot be deserialized.
By introducing
GenericTimestampRequest
this problem is avoided.For validation, a timestamp is only needed and
GenericTimestampRequest
provides only that information.Testing
Types of changes
Checklist
License