cdktf get crashes with "Cannot read properties of undefined (reading \u2018hasOwnProperty\u2019)"
Diagnoses the cdktf get crash when generating bindings for a module (e.g. from a private registry) whose variable definitions confuse the code generator. Covers inspecting the module variables, simplifying them, and falling back to local generation. Use when cdktf get crashes with the hasOwnProperty TypeError. Not for provider download failures.
TL;DR
The module's variable definitions contain a shape the generator does not handle. Inspect the module's variables block, simplify unusual definitions (computed defaults, null-typed variables), and re-run cdktf get. If it still crashes, generate bindings from a local copy of the module.
The error
Cannot read properties of undefined (reading 'hasOwnProperty')Seen while cdktf get downloads and generates a module from a private registry.
Fix it
- Re-run with debug logging:
CDKTF_LOG_LEVEL=all cdktf getand find which module/variable triggers the crash. - Look at the module's variable definitions; remove or simplify exotic constructs (dynamic defaults referencing other variables, deeply nested optional objects).
- If the module is yours, publish a simplified version; if third-party, vendor a local copy and point the module source at the local path.
- Re-run
cdktf get.
Expected result: bindings generate without the TypeError.
When to use this
cdktf getcrashes with "Cannot read properties of undefined (reading 'hasOwnProperty')"- The crash happens while generating a module (not a provider)
When NOT to use this
cdktf getfails to download the module (registry auth/network issue)- The crash names a provider (different code path)
Root cause
The code generator walks the module's variable schema and assumes certain fields exist; some valid Terraform variable definitions (common in private-registry modules) violate that assumption, so the generator dereferences undefined. The maintainer's diagnosis points at the variable section of the module definition.
Edge cases
- Setting
codeMakerOutputdoes not matter here; the crash is in schema walking, not output. - HCL-native Terraform consumes the same module fine; the bug is CDKTF-generator-specific.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.