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

CDKTF convert: Internal Error: unexpected array #3526

Closed
1 task
scraly opened this issue Feb 27, 2024 · 3 comments · Fixed by #3578
Closed
1 task

CDKTF convert: Internal Error: unexpected array #3526

scraly opened this issue Feb 27, 2024 · 3 comments · Fixed by #3578
Labels
bug Something isn't working priority/important-soon High priority, to be worked on as part of our current release or the following one.

Comments

@scraly
Copy link

scraly commented Feb 27, 2024

Expected Behavior

$ echo 'resource "ovh_cloud_project_kube" "my_kube_cluster" {
  name         = "my_kube_cluster_cdktf"
  region       = "GRA7"
}' | cdktf convert --language go --provider 'ovh/ovh'

--> providing the Go file with the code generated according to the OVH provider (https://registry.terraform.io/providers/ovh/ovh/latest)

Actual Behavior

Executing the covert command cause an error: Internal Error: unexpected array

$ echo 'resource "ovh_cloud_project_kube" "my_kube_cluster" {
  name         = "my_kube_cluster_cdktf"
  region       = "GRA7"
}' | cdktf convert --language go --provider 'ovh/ovh'
Internal Error: unexpected array
Error: unexpected array
    at Parser.renderAttributeType (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:205:23)
    at Parser.renderAttributesForBlock (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:264:31)
    at Parser.resourceFrom (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:124:31)
    at ResourceParser.parse (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:458:33)
    at /home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:121
    at Array.map (<anonymous>)
    at TerraformProviderGenerator.buildResourceModels (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:75)
    at /home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:93:31
    at Array.reduce (<anonymous>)
    at convertToTypescript (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:91:79)
Collecting Debug Information...
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: unexpected array
    at Parser.renderAttributeType (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:205:23)
    at Parser.renderAttributesForBlock (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:264:31)
    at Parser.resourceFrom (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:124:31)
    at ResourceParser.parse (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:458:33)
    at /home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:121
    at Array.map (<anonymous>)
    at TerraformProviderGenerator.buildResourceModels (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:75)
    at /home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:93:31
    at Array.reduce (<anonymous>)
    at convertToTypescript (/home/linuxbrew/.linuxbrew/Cellar/cdktf/0.20.3/libexec/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:91:79)
(node:77841) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)
(Use `node --trace-warnings ...` to show where the warning was created)
Debug Information:
language: typescript
cdktf-cli: 0.20.3
node: v20.11.1
cdktf: 0.20.4
constructs: 10.3.0
jsii: null
terraform: 1.5.7
arch: x64
os: linux 6.1.75-060175-generic

Steps to Reproduce

  1. execute
    $ echo 'resource "ovh_cloud_project_kube" "my_kube_cluster" { name = "my_kube_cluster_cdktf" region = "GRA7" }' | cdktf convert --language go --provider 'ovh/ovh'

  2. Show the error message

Versions

language: typescript
cdktf-cli: 0.20.3
node: v20.11.1
cdktf: 0.20.4
constructs: 10.3.0
jsii: null
terraform: 1.5.7
arch: x64
os: linux 6.1.75-060175-generic

Providers

┌───────────────┬──────────────────┬───────┬────────────┬──────────────┬─────────────────┐
│ Provider Name │ Provider Version │ CDKTF │ Constraint │ Package Name │ Package Version │
├───────────────┼──────────────────┼───────┼────────────┼──────────────┼─────────────────┤
│ ovh/ovh │ 0.37.0 │ │ ~>0.37.0 │ │ │
└───────────────┴──────────────────┴───────┴────────────┴──────────────┴─────────────────┘

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

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
@scraly scraly added bug Something isn't working new Un-triaged issue labels Feb 27, 2024
@rick-wojciechowski-imprivata

Any word on this? 3111 has been closed. 3170 waiting on answer status was removed by bot which seems like an inappropriate action setting. I am seeing this same issue on conversion to python. If anyone knows a combination of cdktf and node versions that work, please advise.

@mutahhir
Copy link
Member

I am unsure why this is happening yet.

The core reason for the (unhelpful, I must add) error is that the provider schema that we're trying to convert seems to be wrong. For each list or set attribute type, it should be an array with two elements, the first one informing us whether it's a set or a list, and the second is the value type. In the above case, we're getting four elements, which are basically two elements duplicated again.

I tried to chase down where this is coming from, but it isn't clear yet. I'll continue to investigate this.

@mutahhir mutahhir added priority/important-soon High priority, to be worked on as part of our current release or the following one. and removed new Un-triaged issue labels Mar 25, 2024
Copy link
Contributor

github-actions bot commented May 3, 2024

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 May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working priority/important-soon High priority, to be worked on as part of our current release or the following one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants