Skip to content

fix(lambda): show received ephemeral storage size instead of [object Object] - #38734

Closed
sanyamk23 wants to merge 4 commits into
aws:mainfrom
sanyamk23:fix/lambda-ephemeral-storage-error
Closed

sanyamk23 wants to merge 4 commits into
aws:mainfrom
sanyamk23:fix/lambda-ephemeral-storage-error

Conversation

@sanyamk23

Copy link
Copy Markdown
Contributor

The out-of-range error interpolated the Size object directly into the message. Size has no toString(), so the value rendered as [object Object] and gave no indication of what was actually passed. Convert to mebibytes in the message, matching the conversion already performed by the range check on the line above.

Fixes #38621

…Object]

The out-of-range error interpolated the Size object directly into the
message. Size has no toString(), so the value rendered as
[object Object] and gave no indication of what was actually passed.
Convert to mebibytes in the message, matching the conversion already
performed by the range check on the line above.

Fixes aws#38621
@aws-cdk-automation
aws-cdk-automation requested a review from a team September 1, 2026 19:56
@github-actions github-actions Bot added effort/medium Medium work item – several days of effort p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Sep 1, 2026

@aws-cdk-automation aws-cdk-automation left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

The linter requires an integration test file and snapshot when
fixing validation error messages. This test exercises a valid
ephemeral storage size to ensure the out-of-range check passes
after the error message fix.
The Size class is exported from aws-cdk-lib (via core), not from
aws-cdk-lib/aws-lambda. Fix the import to resolve the build error:
"Property 'Size' does not exist on type 'typeof import(...aws-lambda/index)'".
@aws-cdk-automation
aws-cdk-automation dismissed their stale review September 3, 2026 15:39

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 3, 2026

@lpizzinidev lpizzinidev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for the contribution! However, the change is no longer necessary after #38662

@maintainer-for-aws

Copy link
Copy Markdown

Automated review

A maintainer will still review this — treat the notes below as a starting point.

This PR improves the EphemeralStorageOutOfRange validation error in the Lambda Function construct: when ephemeralStorageSize is out of the 512–10240 range, the message now interpolates ephemeralStorageSize.toMebibytes() MiB instead of the raw Size object (which rendered as [object Object]). The validation logic, error code, and public API are unchanged. A unit test is tightened to assert the new message text, and a new integ test with snapshot is added.

The fix is low-risk and message-only: toMebibytes() is called inside a branch already guarded by !isUnresolved(), so there is no token or undefined risk, and the tightened unit test discharges the coverage the change owes. The one point worth a look is whether the added integ test — which exercises only a valid path and cannot reach the changed error path — earns its new snapshot for a cosmetic fix.

🔴 0 blocking · 🟡 0 recommended · ⚪ 1 optional

Files with findings (1)
File Findings
packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-ephemeral-storage-validation.ts ⚪ 1

Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews.

@maintainer-for-aws maintainer-for-aws Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review summary comment for the overview; the notes below are inline.

Comment on lines +13 to +21
// A valid ephemeral storage size (within 512-10240 MiB range).
// This validates that the out-of-range check passes for valid inputs
// after the error message fix was applied.
new lambda.Function(stack, 'LambdaWithEphemeralStorage', {
runtime: lambda.Runtime.NODEJS_20_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = async () => {};'),
ephemeralStorageSize: Size.mebibytes(1024),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Optional — This new integ test exercises only a valid ephemeral storage size (Size.mebibytes(1024)), so it never touches the out-of-range error path this change actually fixes — and it cannot, since an out-of-range value throws at synth time and can never be deployed. The behavior under change is a validation message string, which the tightened unit test already covers and catches regressions for. The test's own comment references an "out-of-range check" the test does not trigger, and the result is a new synthesized snapshot for a cosmetic message change (INTEGRATION_TESTS.md).

Suggested change: Consider dropping the integ test and its snapshot and relying on the unit-test update alone, since the changed error string is only coverable at the unit level. If the intent is genuinely to add first-time deploy coverage for ephemeralStorageSize, keep the test but update the comment to state that goal rather than referencing an out-of-range check it never triggers.

@rix0rrr rix0rrr closed this Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 25, 2026

This branch was successfully deployed

1 active deployment
automation — 22dd6118 Deployed Sep 25, 2026 by gjurova via validate-pr #369372
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr/request-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-lambda): ephemeral storage validation error reports [object Object] instead of the received size

5 participants