Skip to content

fix(region-info): standalone use of @aws-cdk/region-info throws an Cannot find module 'aws-cdk-lib/core/lib/errors' error#36414

Merged
mergify[bot] merged 3 commits intomainfrom
mrgrain/fix/region-info/standalone-usage-error
Dec 17, 2025
Merged

fix(region-info): standalone use of @aws-cdk/region-info throws an Cannot find module 'aws-cdk-lib/core/lib/errors' error#36414
mergify[bot] merged 3 commits intomainfrom
mrgrain/fix/region-info/standalone-usage-error

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Dec 17, 2025

Issue # (if applicable)

Closes #36399.

Reason for this change

The @aws-cdk/region-info package imports UnscopedValidationError from an internal aws-cdk-lib path (aws-cdk-lib/core/lib/errors). Since aws-cdk-lib is only a devDependency, users installing @aws-cdk/region-info standalone get a "Cannot find module" error when using the package.

Description of changes

Introduce a local RegionFactError class that:

  • Extends Error and uses CONSTRUCT_ERROR_SYMBOL for typed error detection via Errors.isConstructError()
  • Sets name to 'RegionFactError' for consistent error presentation to users
  • Removes the dependency on the internal aws-cdk-lib/core/lib/errors import

Also adds an ESLint rule to region-info/lib/ that prevents imports from ../../* paths, ensuring this issue cannot regress.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

  • Built aws-cdk-lib successfully
  • Ran region-info tests in both aws-cdk-lib and @aws-cdk/region-info packages
  • Verified ESLint rule catches violations

Checklist


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

Introduce a local `RegionFactError` class that uses `CONSTRUCT_ERROR_SYMBOL`
instead of importing `UnscopedValidationError` from an internal aws-cdk-lib path.

This allows `@aws-cdk/region-info` to work standalone without requiring
`aws-cdk-lib` as a runtime dependency while maintaining typed error support.
@aws-cdk-automation aws-cdk-automation requested a review from a team December 17, 2025 11:03
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Dec 17, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 17, 2025
Copy link
Copy Markdown
Collaborator

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

Choose a reason for hiding this comment

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

(This review is outdated)

@mrgrain mrgrain force-pushed the mrgrain/fix/region-info/standalone-usage-error branch from 1f86990 to b81df8d Compare December 17, 2025 11:09
@mrgrain mrgrain changed the title fix(region-info): use local error class for standalone package usage fix(region-info): standalone use of @aws-cdk/region-info throws an Cannot find module 'aws-cdk-lib/core/lib/errors' error Dec 17, 2025
@mrgrain mrgrain added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Dec 17, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review December 17, 2025 11:50

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

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 17, 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 01c7d2e into main Dec 17, 2025
31 of 32 checks passed
@mergify mergify bot deleted the mrgrain/fix/region-info/standalone-usage-error branch December 17, 2025 12:19
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 17, 2025

Merge Queue Status

✅ The pull request has been merged at e97d550

This pull request spent 8 seconds in the queue, including 1 second running CI.
The checks were run in-place.

Required conditions to merge

@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 Dec 17, 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/medium Medium work item – several days of effort p1 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-test The PR linter will not require test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(node: @aws-cdk/region-info): using latest version of @aws-cdk/region-info throws an "Cannot find module 'aws-cdk-lib/core/lib/errors'" error

3 participants