You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Latent bug (pre-existing at the merge base of #296)
TFExpression.resolveExpressionPart (packages/cdktn/src/tfExpression.ts) renders object arguments key by key as:
`"${key}" = ${this.resolveArg(context,arg[key])}`
The key is interpolated into the quoted Terraform string literal verbatim. A key containing a quote, backslash, control character, ${...}, or %{...} therefore either produces an invalid Terraform expression or silently turns the literal key into a Terraform template sequence.
Repro scenarios
// 1. Quote in key: renders {"he"llo" = "x"} - invalid HCLnewTerraformOutput(stack,"out",{value: Fn.lookup(Token.asAny({'he"llo': "x"}),"other"),});// 2. Template marker in key: renders {"${injected}" = "x"} - the key// becomes a template interpolation instead of the literal stringFn.lookup(Token.asAny({"${injected}": "x"}),"other");// 3. Backslash in key: renders {"a\b" = ...} - "\b" is an invalid (or// unintended control) escape in the resulting Terraform string literalFn.lookup(Token.asAny({"a\\b": "x"}),"other");
Scope
The direct-object branch of resolveExpressionPart (pre-existing).
PR feat: support newer provider plugin-protocol features via targetVersions (RFC-04) #296 fixed the newly added resolvable-resolved-object branch (whole-collection tokens like Token.asAny({...}) passed to provider functions) to serialize keys as proper quoted-string literals (JSON.stringify + $${/%%{ template-marker escaping) — the same treatment should be applied here.
Audit the HCL renderer's map/object rendering for the same pattern while at it.
See the discussion in #296 (review comment on tfExpression.ts and #296 (comment)).
Latent bug (pre-existing at the merge base of #296)
TFExpression.resolveExpressionPart(packages/cdktn/src/tfExpression.ts) renders object arguments key by key as:`"${key}" = ${this.resolveArg(context, arg[key])}`The key is interpolated into the quoted Terraform string literal verbatim. A key containing a quote, backslash, control character,
${...}, or%{...}therefore either produces an invalid Terraform expression or silently turns the literal key into a Terraform template sequence.Repro scenarios
Scope
resolveExpressionPart(pre-existing).Token.asAny({...})passed to provider functions) to serialize keys as proper quoted-string literals (JSON.stringify+$${/%%{template-marker escaping) — the same treatment should be applied here.See the discussion in #296 (review comment on tfExpression.ts and #296 (comment)).