Skip to content
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

[BUG] (type-safe-api) PrepareSpec function name too long #615

Closed
jstrunk opened this issue Oct 26, 2023 · 1 comment · Fixed by #619
Closed

[BUG] (type-safe-api) PrepareSpec function name too long #615

jstrunk opened this issue Oct 26, 2023 · 1 comment · Fixed by #619
Labels
bug Something isn't working

Comments

@jstrunk
Copy link
Contributor

jstrunk commented Oct 26, 2023

Describe the bug

type-safe-api generates prepareSpecLambdaName using the stack prefix. When used with a branch name and stack name over a certain length, it causes a function name longer than 64 characters which is the limit from Lambda.

Expected Behavior

All generated function names will be less than 64 characters in length.

Current Behavior

cdk synth fails with Error: Function name can not be longer than 64 characters but has 66 characters.

The full error message before this exception appears to be a dump of a javascript source.

Reproduction Steps

Create a stack with a type-safe-api in a stack with a name over 34 characters long. Or use PDK Pipeline with feature branches enabled and have the combination of the branch name and the stack name over 34 characters long. e.g. feature-branch-Dev-MyLongStackName.

cdk synth will fail

Possible Solution

https://github.com/aws/aws-pdk/blob/4057d69b68e329d7434af4c3cd0ef7d17856c8b2/packages/type-safe-api/src/construct/type-safe-rest-api.ts#L128C11-L128C32 generates the ParseSpec name.

const providerFunctionName = `${prepareSpecLambdaName}-Provider`;
uses it and appends "-Provider" for a second function.

Create a function to check the length and generate a shorter alternative.

Additional Information/Context

No response

PDK version used

0.22.17

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

MacOS 13.6

@jstrunk jstrunk added the bug Something isn't working label Oct 26, 2023
cogwirrel added a commit that referenced this issue Oct 30, 2023
…ngth

Truncate the lambda function names for the custom resource to ensure they are below the max length
of 64 characters.

Fixes #615
cogwirrel added a commit that referenced this issue Oct 30, 2023
…ngth (#619)

Truncate the lambda function names for the custom resource to ensure they are below the max length
of 64 characters.

Fixes #615
@cogwirrel
Copy link
Member

Thanks for reporting this Jeff! Fixed in 0.22.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants