Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Found an encoded list token string in a scalar string context easier to debug #1890

Closed
DanielMSchmidt opened this issue Jun 22, 2022 · 2 comments · Fixed by #3300
Closed
Assignees
Labels
cdktf enhancement New feature or request priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. size/small estimated < 1 day ux/debugging
Milestone

Comments

@DanielMSchmidt
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Currently those errors come with stack traces like this:

    /Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:127
          throw new Error(
                ^
    Error: Found an encoded list token string in a scalar string context. Use 'Fn.element(list, 0)' (not 'list[0]') to extract elements from token lists
        at resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:127:13)
        at Object.resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:70:16)
        at resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:244:39)
        at Object.resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:70:16)
        at resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:244:39)
        at Object.resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:70:16)
        at resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:244:39)
        at Object.resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:70:16)
        at Object.resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/private/resolve.ts:244:39)
        at Function.resolve (/Users/danielschmidt/work/demos/cdktf-aws-networking-demo/node_modules/cdktf/lib/tokens/token.ts:244:12)

Adding information like which construct / property caused the error would be great, especially for users changing a lot of code at once, it's super hard to pin point where the error stems from

References

@DanielMSchmidt DanielMSchmidt added enhancement New feature or request new Un-triaged issue cdktf needs-priority Issue has not yet been prioritized; this will prompt team review ux/debugging size/small estimated < 1 day size/medium estimated < 1 week and removed new Un-triaged issue size/small estimated < 1 day labels Jun 22, 2022
@DanielMSchmidt DanielMSchmidt added priority/important-soon High priority, to be worked on as part of our current release or the following one. size/small estimated < 1 day and removed size/medium estimated < 1 week needs-priority Issue has not yet been prioritized; this will prompt team review labels Jul 15, 2022
@daiwei920
Copy link

It is not a bug, I found the solution:
import { Fn } from 'cdktf';
Use Fn.element(this.vpc.subnetIds, 0)
More detail, read: https://www.terraform.io/cdktf/concepts/functions

@xiehan xiehan added priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. and removed priority/important-soon High priority, to be worked on as part of our current release or the following one. labels Jun 1, 2023
@mutahhir mutahhir added this to the 0.20 (tentative) milestone Nov 24, 2023
@DanielMSchmidt DanielMSchmidt self-assigned this Nov 28, 2023
Copy link
Contributor

I'm going to lock this issue 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 similar to this, 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 Dec 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cdktf enhancement New feature or request priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. size/small estimated < 1 day ux/debugging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants