-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
LambdaRestApi doesn't add the handler when .withOptions is used #965
Comments
+1. Just discovered this an almost filed a dupe. I think this can be traced to the constructor for |
Oh man, that should be a jsii compliance test! |
On it |
Oh JavaScript. TIL: console.log({
...{
hello: 'hello'
},
...{
hello: undefined
}
}); Returns: { hello: undefined } Which was not what I expected, and will make it harder to solve this. |
The current behavior of the Java bindings is that data types (created through the generated builders) are basically normal classes that implement the jsii interface and when passed to the js code they are passed by reference and not serialized into a JSON object. This means that when the JS code wants to read a property value (i.e. |
Sounds like an interesting general problem to solve, but for this case specifically would simply flipping order solve the issue? Going from:
to
props.handler is required and props.options.defaultIntegration is specifically forbidden. |
Ideally we want to solve this at the right layer (i.e. jsii) so that user code (i.e. CDK) will not have to be aware of these cross-language quirks. |
Understood. But there is nothing intrinsically right or wrong about either ordering above (i.e. changing it does not make the code better or worse), so if the ideal fix is significant effort+time it would be nice to consider a short term solution for this particular case. |
Implement a serialization method for Java POJOs (produced by calling `build()` on the generated builders such that they are passed by-value to JavaScript instead of by-reference. Also, erase any nulls passed in objects to JS, so they are treated as unset values for the purpose of `key in obj`. This fixes aws/aws-cdk#965 and fixes #375.
Hopefully we will be able to fix it at the source: aws/jsii#376 |
👍 |
Implement a serialization method for Java POJOs (produced by calling `build()` on the generated builders such that they are passed by-value to JavaScript instead of by-reference. Also, erase any nulls passed in objects to JS, so they are treated as unset values for the purpose of `key in obj`. This fixes aws/aws-cdk#965 and fixes #375.
Data types ("structs") are defined through a TypeScript interface that only contains properties and doesn't begin with an `I`. This change also adds a requirement that all properties (shallow) are marked `readonly`. This allows passing around structs by-value safely because any consuming code would not expect to be able to write to the object. Python already passes structs by value, especially in the context of when a struct is used as keyword arguments. This use case will also exist in Ruby. This is also the general perception around data that's passed around in most programming languages. To enforce this, the jsii compiler will now fail if a struct includes properties that are not marked `readonly`. Both the Java and .NET generators have been modified to generate builders which allow users to construct structs by serializing them as JSON hashes instead of passed down by reference. Existing compliance tests in all languages have been fixed. This change fixes aws/aws-cdk#965 and fixes #375 by erasing any `null`s or `undefined` values from passed in objects, so they do not appear to have been defined at all. Added a compliance test called **erase-unset-data-values** to verify. BREAKING CHANGE: all properties in interfaces which represent data types must be marked as `readonly`. Otherwise, jsii compilation will fail.
If I do this - I end up with the Lambda Handler not added to the {proxy+} and instead it points to MOCK
If I remove the .withOptions, then handler is correctly added and the API works.
The text was updated successfully, but these errors were encountered: