Skip to content

(software.amazon.awscdk.services.lambda.Function): Recursive folder creation in cdk.out when lambda jar path is mentioned as ""  #29410

@lohithsamaga

Description

@lohithsamaga

Describe the bug

When creating a lambda function using CDK Java, if the lambda jar file path mentioned as "" in the Code parameter, the synth/diff/deploy process initiates an infinite recursive creation of directories "cdk.out/asset-xxx/cdk.out/asset-xxx/,,,".
It throws an error at the end when the file path is too deep. There is no warning if the asset folder is not mentioned.
Also this leads to a blue screen when the project is opened in Eclipse.

Please fix this issue.

Expected Behavior

Throw an error that the asset path is not provided.

Current Behavior

Creation of infinite nested folders.

Reproduction Steps

FunctionProps props = FunctionProps.builder()
    	.code(Code.fromAsset(""))
    	.handler("com.example.action.handler.MyAction")
    	.functionName("MyFunction")
    	.runtime(Runtime.JAVA_11)
    	.logRetention(RetentionDays.ONE_WEEK)
    	.role(f1Role)
    	.build();
	
	Function f1 = new Function(this,"Fun", props);

Possible Solution

Stop the synthesis and throw an error message that the asset path cannot be a zero-lenth string.

Additional Information/Context

No response

CDK CLI Version

2.102.0

Framework Version

2.102.0

Node.js Version

v18.16.0

OS

Windows 10

Language

Java

Language Version

11

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-lambdaRelated to AWS LambdabugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions