Describe the bug
This commit in aws-lambda adds a check for the presence of a security groups parameter if the VPC parameter is not present. Since TypeScript treats empty arrays as true, the check for the securityGroups parameter evaluates to true when an empty array is passed in for FunctionProps.securityGroups.
Expected Behavior
This condition checking for the presence of FunctionProps.securityGroups should evaluate to false if FunctionProps.securityGroups is an empty array.
Current Behavior
This condition checking for the presence of FunctionProps.securityGroups should evaluate to true if FunctionProps.securityGroups is an empty array.
Reproduction Steps
Pass in an empty array for the securityGroups field and no value for the vpc field in FunctionProps when calling Function::configureVpc method.
Possible Solution
Explicitly check for empty arrays in addition to the current truthiness check.
Additional Information/Context
No response
CDK CLI Version
2.93.0
Framework Version
No response
Node.js Version
14.19.1
OS
Linux
Language
Typescript
Language Version
No response
Other information
No response
Describe the bug
This commit in aws-lambda adds a check for the presence of a security groups parameter if the VPC parameter is not present. Since TypeScript treats empty arrays as
true, the check for thesecurityGroupsparameter evaluates to true when an empty array is passed in forFunctionProps.securityGroups.Expected Behavior
This condition checking for the presence of
FunctionProps.securityGroupsshould evaluate tofalseifFunctionProps.securityGroupsis an empty array.Current Behavior
This condition checking for the presence of
FunctionProps.securityGroupsshould evaluate totrueifFunctionProps.securityGroupsis an empty array.Reproduction Steps
Pass in an empty array for the
securityGroupsfield and no value for thevpcfield inFunctionPropswhen callingFunction::configureVpcmethod.Possible Solution
Explicitly check for empty arrays in addition to the current truthiness check.
Additional Information/Context
No response
CDK CLI Version
2.93.0
Framework Version
No response
Node.js Version
14.19.1
OS
Linux
Language
Typescript
Language Version
No response
Other information
No response