Skip to content

fix(lib): fail on constructs outside of stacks (under feature flag) - #93

Merged
jsteinich merged 5 commits into
open-constructs:mainfrom
krzema12:fail-on-resources-outside-of-stacks
Apr 14, 2026
Merged

jsteinich merged 5 commits into
open-constructs:mainfrom
krzema12:fail-on-resources-outside-of-stacks

Conversation

@krzema12

@krzema12 krzema12 commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Fixes #57

Description

Adds extra validation (enabled with a feature flag) that catches constructs outside of stacks. Such constructs aren't rendered in output of any stack, which is misleading. One can assume that there's some app's implicit stack or that the resource will somehow be rendered and deployed, but it's not true. This change is a step towards stricter validation of this case.

⚠️ BREAKING CHANGE
If the feature flag is enabled, apps having constructs with the app itself as their scope will fail to synthesize. Only constructs with stacks or their descendants as their scope are legal.

Checklist

  • I have updated the PR title to match CDKTN's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

@krzema12
krzema12 marked this pull request as ready for review April 9, 2026 07:13
@krzema12
krzema12 requested a review from a team as a code owner April 9, 2026 07:13
Comment thread packages/cdktn/lib/features.ts Resolved
@krzema12
krzema12 requested a review from jsteinich April 11, 2026 20:02
Comment thread packages/cdktn/lib/features.ts Resolved
@krzema12
krzema12 requested a review from jsteinich April 12, 2026 18:41
@jsteinich
jsteinich enabled auto-merge (squash) April 14, 2026 01:43
@jsteinich
jsteinich merged commit 1e4f5d2 into open-constructs:main Apr 14, 2026
527 of 529 checks passed
jsteinich added a commit that referenced this pull request May 6, 2026
**Breaking changes**

### Python 3.8 is no longer supported

We have dropped support for Python 3.8, please update to Python 3.9 or
higher.

### Go 1.18-1.24 are no longer supported

We have dropped support for Go 1.18 - 1.24, please update to Go 1.25 or
higher.

### TypeScript versions less than 4.5 are no longer suppored

Provider generation now uses features from TypeScript 4.5.
Note that there isn't an official minimum supported TypeScript at this
time and using the latest 5.x version is recommended.

**Upcoming Breaking Changes**

Node version 22.x will become the minimum in an upcoming release as 20.x
is now EoL.

### feat

- feat(provider-generator): use type modifier on imports
[\#150](#150)
- feat(lib): add StringMapMap class
[\#110](#110)

### chore

- chore: clean up yarn install warnings
[\#149](#149)
- chore(deps): bump the github-actions-backward-compatible group with 6
updates [\#146](#146)
- chore: Fix eslint warnings - phase 5
[\#140](#140)
- chore: Fix eslint warnings - phase 4
[\#139](#139)
- chore: Fix eslint warnings - phase 3
[\#138](#138)
- chore: Fix eslint warnings - phase 2
[\#137](#137)
- chore: Fix eslint warnings - phase 1
[\#135](#135)
- chore(provider-generator): Update retry to terraform init for
transient GitHub errors
[\#134](#134)
- chore: Remove unused dependencies from packages - phase 1
[\#133](#133)
- chore(provider-generator): Add retry to terraform init for transient
GitHub errors
[\#132](#132)
- chore(provider-generator): enable typescript declarationMap
[\#131](#131)
- chore: Fix Java flaky integration test
[\#130](#130)
- chore: Add missing dependencies to packages
[\#129](#129)
- chore: Standardise test scripts to only run tests
[\#128](#128)
- chore: Remove edited from the examples workflow pull_request types
[\#127](#127)
- chore: Add retry to build-example
[\#126](#126)
- chore: Bump verdaccio version and add npm install retries
[\#122](#122)
- chore: Remove `edited` from the test workflow pull_request types
[\#121](#121)
- chore: Replace depcheck CI check with knip
[\#120](#120)
- chore: Update test providers to support darwin arm64
[\#119](#119)
- chore: Refine eslint configuration
[\#118](#118)
- chore: emit compiled TS to build/ instead of next to sources
[\#116](#116)
- chore: Add VSCode Settings and Extension Recommendations
[\#114](#114)
- chore: Fix eslint auto-fixable issues
[\#113](#113)
- chore: use new docker image in builds
[\#108](#108)
- chore: Update docker image to have Go 1.25 and Node 22
[\#97](#97)
- chore: Upgrade dependencies for all
[\#91](#91)
- chore: Upgrade jest to v30
[\#89](#89)
- chore(deps): bump the github-actions-backward-compatible group with 4
updates [\#88](#88)
- chore(deps): bump the github-actions-breaking group with 5 updates
[\#87](#87)
- chore: add migration context to bug report issue templates [skip ci]
[\#86](#86)
- chore: npm-check-updates && yarn upgrade
[\#84](#84)
- chore: Upgrade dependencies for all
[\#83](#83)
- chore(lib): add test showing no failure if resource scoped to app
[\#73](#73)
- chore(deps): Run npx yarn-audit-fix --force
[\#59](#59)
- chore(cli): Replace node-pty with simple interactive process
[\#55](#55)
- chore: Upgrade dependencies for JSII
[\#20](#20)

### fix

- fix(cli): anchor jest testPathIgnorePatterns in typescript template
[\#147](#147)
- fix(tests): Fix app.test and json-to-hcl.test race condition
[\#125](#125)
- fix(lib): ForExpression missing iteratorContext and OperatorExpression
drops falsy right operands
[\#112](#112)
- fix(cli): support pre-built provider metadata with cdktn key
[\#107](#107)
- fix(cli): don't check cdktf-cli version
[\#99](#99)
- fix(deps): replace archiver with yazl
[\#95](#95)
- fix(lib): fail on constructs outside of stacks (under feature flag)
[\#93](#93)
- fix(gha): Fix GitHub release creation
[\#90](#90)
@github-actions

Copy link
Copy Markdown
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cdktn: synthesis succeeds if resource is added with app's scope

2 participants