Skip to content

fix(cli): Fix input getting split between cdktn and Terraform - #191

Merged
jsteinich merged 1 commit into
open-constructs:mainfrom
jsteinich:fix/187
May 23, 2026
Merged

jsteinich merged 1 commit into
open-constructs:mainfrom
jsteinich:fix/187

Conversation

@jsteinich

@jsteinich jsteinich commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Fixes #187

Description

The fix forces the child Terraform process to have its own piped stdin instead of inheriting the user's TTY.

The bug: PR #55 set stdio[0] based on process.stdin.writable:

  • In an interactive terminal, process.stdin.writable === true, so it picked "inherit".
  • "inherit" means the child's stdin is the parent's stdin — the same TTY file descriptor.

So when cdktn ran terraform apply interactively, both processes were reading from the same TTY:

  • cdktn's Ink picker needed keystrokes for Approve/Dismiss/Stop.
  • Terraform was sitting on Enter a value: waiting for yes/no.

Each keystroke went to whichever reader the kernel happened to deliver it to. Roughly half went to Terraform (and got discarded — Terraform was waiting for newline-terminated input, not arrow keys), the rest reached Ink. That's why ~5 of 8 keystrokes vanished and the picker felt broken.

The fix: stdio[0] = "pipe" gives Terraform its own stdin pipe owned by cdktn. Terraform reads from that pipe, not from the user's TTY. The user's keystrokes go only to cdktn → Ink → the picker. When the user picks Approve/Reject, cdktn writes "yes\n" or "no\n" into that pipe via actions.writeLine, which it was already wired up to do (deploy-machine.ts:233/240).
The original code's comment said "Generally want interactive input for handling various prompts" — but cdktn doesn't actually need to forward user keystrokes to Terraform. It intercepts every prompt via stdout pattern-matching and synthesises the response itself.

Investigation from @X-Guardian

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

@jsteinich
jsteinich marked this pull request as ready for review May 22, 2026 14:04
@jsteinich
jsteinich requested a review from a team as a code owner May 22, 2026 14:04

@so0k so0k 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.

Thanks @X-Guardian and @jsteinich

@jsteinich
jsteinich merged commit fcf7392 into open-constructs:main May 23, 2026
269 checks passed
@jsteinich
jsteinich deleted the fix/187 branch May 23, 2026 15:57
jsteinich added a commit that referenced this pull request May 26, 2026
## 0.23.2

### chore
- chore: Update npm version to support OIDC trusted publishing
[\#205](#205)
- chore: Fix publib running to use npx rather than yarn
[\#203](#203)
- chore(tests): Add test for Node type stripping
[\#198](#198)
- chore(gha): Enable NPM OIDC Publishing
[\#195](#195)
- chore: remove mention of Hashicorp support
[\#193](#193)
- chore: consolidate release workflows for npm OIDC
[\#192](#192)
- chore: tell users to search for cdktn on npm
[\#185](#185)
- chore: replace cdk.tf/modules-and-providers links
[\#184](#184)
- chore: fix references to cdktf in TS examples
[\#183](#183)
- chore: point to correct docs repo
[\#181](#181)
- chore: delete Vercel config for cdk.tf site
[\#180](#180)
- chore(gha): optimise integration & provider-integration CI pipelines
[\#178](#178)
- chore(gha): optimise examples CI pipeline
[\#175](#175)
- chore: migrate jest to @nx/jest plugin with swc-jest
[\#160](#160)
- chore: replace yazl with fflate
[\#148](#148)
- chore(lib): Move cdktn package to src/ and lib/ layout
[\#145](#145)
- chore: Consolidate PR CI into tiered orchestrator workflow
[\#143](#143)

### fix

- fix(gha): Need to grant permission on workflow call job
[\#196](#196)
- fix(cli): Fix input getting split between cdktn and Terraform
[\#191](#191)
- fix(cli): restore non-bundled dependencies
[\#190](#190)
- fix: Configurable dist artifact name to fix release workflows
[\#189](#189)
- fix(tests): pass --no-compile to pip in python integration tests
[\#188](#188)
- fix(cli): pass languageOptions to `get`
[\#179](#179)
- fix(provider-generator): add missing semicolons
[\#177](#177)

### feat

- feat(provider-generator): configurable import extensions
[\#151](#151)
@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 Jun 23, 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-cli: Deployment options not working as expected

3 participants