Skip to content

Conversation

@Abogical
Copy link
Member

Issue # (if applicable)

Closes #21630.

Reason for this change

In the ESM module system, callsites returns filenames prefixed with 'file://'. This is not compatible with the NodeJS file utility functions such as fs.existsSync().

Description of changes

Remove 'file://' prefix.

Describe any new or updated permissions being added

No new IAM permissions are added.

Description of how you validated changes

Unit tests. Integration test cannot be added as the integration test system uses CommonJS, it will be impossible to replicate the error which only happens under an ESM system.

Credits

This is mostly inspired by @okko for his PR. He found the root cause and fix for this issue, but it didn't get merged due to a lack of integration tests.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

In the ESM module system, callsites returns filenames prefixed with 'file://'. This is not compatible with the NodeJS file utility functions such as fs.existsSync().

Fixes #21630
@Abogical Abogical added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Oct 21, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team October 21, 2025 14:06
@github-actions github-actions bot added star-contributor [Pilot] contributed between 25-49 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p2 labels Oct 21, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 21, 2025
@aemada-aws aemada-aws self-assigned this Oct 21, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 21, 2025
Co-authored-by: aemada-aws <[email protected]>
@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot added the queued label Oct 22, 2025
@mergify
Copy link
Contributor

mergify bot commented Oct 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 7becd79 into main Oct 22, 2025
18 of 19 checks passed
@mergify mergify bot deleted the fix-esm-callsites branch October 22, 2025 12:33
@mergify mergify bot removed the queued label Oct 22, 2025
@github-actions
Copy link
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 Oct 22, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes star-contributor [Pilot] contributed between 25-49 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-lambda-nodejs: Default entry finding fails when defining file starts with "file://"

4 participants