Skip to content

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

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

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

Conversation

@sanyamk23

Copy link
Copy Markdown
Contributor

Issue # (if applicable)

Closes #38621.

Reason for this change

When ephemeralStorageSize is outside the allowed range, the validation 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.

Description of changes

Convert the size to mebibytes in the error message, matching the conversion the range check on the line above already performs. The value is guaranteed to be resolved (guarded by !isUnresolved()) and convertible (a non-convertible Size already throws in the condition), so this introduces no new failure path.

Updated the existing unit test to assert the full message including the received value (received 511 MiB.).

Describe any new or updated prerequisites

None.

Any behavior changes

Only the error message text — it now states the received size instead of [object Object].

Is this a breaking change to the CDK CLI?

No

Is this a breaking change to the library or any generated client interfaces?

No

The AWS Cognito API only accepts a domain prefix that starts and ends
with a lowercase alphanumeric character, contains only lowercase
alphanumeric characters and hyphens (not leading or trailing), and is
1-63 characters in length. The previous validation accepted any string
of lowercase alphanumerics and hyphens, which allowed invalid values
that fail at deploy time.

Fixes aws#38531
…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
…efix-validation

Snapshot had a leftover CloudFrontEndpoint output that the integ test source no longer produces, causing integ-runner to flag it as a destructive change in CI.
@sanyamk23
sanyamk23 force-pushed the fix/lambda-ephemeral-storage-error-message branch from 0276a98 to 26599a9 Compare August 31, 2026 12:50
@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 Aug 31, 2026
@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 is titled as a Lambda fix — replacing an error message that rendered [object Object] with the resolved ephemeral storage size in MiB — but the diff also ships an unrelated, undescribed Cognito change: it tightens the domainPrefix validation regex in aws-cognito/lib/user-pool-domain.ts from /^[a-z0-9-]+$/ to one that enforces the service contract (1–63 chars, start/end alphanumeric, interior hyphens) and adds a new integration test with a full snapshot.

The two code changes themselves are sound: the Lambda message fix is safe and its unit test is tightened to assert the full message, and the Cognito regex aligns exactly with the documented Cognito domain-prefix constraints, with good unit-test coverage of the new boundaries. The issues found are in the new Cognito integration test, which is not registered as a deployable test case and adds little beyond existing happy-path coverage.

One item worth reconciling before merge, though outside the scope of the findings above: the title and body describe only the Lambda fix while the diff ships a substantive Cognito change with no linked issue, so the two areas may be better split into separate PRs or the description updated to cover both.

🔴 0 blocking · 🟡 1 recommended · ⚪ 1 optional

Files with findings (1)
File Findings
packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-domain-prefix-validation.ts 🟡 1 ⚪ 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 +9 to +31

const app = new App({
postCliContext: {
'@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
},
});
const stack = new Stack(app, 'integ-user-pool-domain-prefix-validation');

const userpool = new UserPool(stack, 'UserPool', {
removalPolicy: RemovalPolicy.DESTROY,
});

// A prefix that exercises the tightened validation: hyphens in the middle are
// allowed, but the prefix must start and end with a lowercase alphanumeric.
const domain = userpool.addDomain('Domain', {
cognitoDomain: {
domainPrefix: 'cdk-integ-user-pool-domain',
},
});

new CfnOutput(stack, 'Domain', {
value: domain.domainName,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Recommended — This new integration test builds an App, Stack, and CfnOutput but never instantiates the IntegTest construct from @aws-cdk/integ-tests-alpha. The integ-runner only treats a file as a deployable test case when it registers one, so as written this file is never deployed by yarn integ and degrades to a bare synth snapshot — the sibling integ.user-pool-domain-managed-login.ts registers a test case (its snapshot contains a DeployAssert stack), while this PR's snapshot template contains only the UserPool and UserPoolDomain and no assertion stack, confirming the omission (INTEGRATION_TESTS.md).

Suggested change: import * as integ from '@aws-cdk/integ-tests-alpha';
// ...
new integ.IntegTest(app, 'IntegTest', { testCases: [stack] });
// then regenerate the snapshot with yarn integ --update-on-failed

Comment on lines +22 to +26
// allowed, but the prefix must start and end with a lowercase alphanumeric.
const domain = userpool.addDomain('Domain', {
cognitoDomain: {
domainPrefix: 'cdk-integ-user-pool-domain',
},

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 — The behavior this PR changes is a synth-time validation tightening of domainPrefix, and a deploy-time integration test cannot assert the rejections (invalid prefixes throw at synth, before any deploy). This test therefore only exercises the happy path of deploying a UserPoolDomain with a valid prefix, which the existing integ.user-pool-domain-managed-login.ts already covers, while the negative and boundary behavior is fully exercised by the new unit tests. Consider whether a separate integ test earns its place here.

This branch was successfully deployed

1 active deployment
automation — 26599a9d Deployed Sep 25, 2026 by gjurova via validate-pr #369373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK 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

3 participants