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

Convert function cdktf-cli always errors with Maximum call stack size exceeded #1247

Closed
nandac opened this issue Nov 3, 2021 · 3 comments · Fixed by #1256
Closed

Convert function cdktf-cli always errors with Maximum call stack size exceeded #1247

nandac opened this issue Nov 3, 2021 · 3 comments · Fixed by #1256
Assignees
Labels
bug Something isn't working confirmed independently reproduced by an engineer on the team feature/convert

Comments

@nandac
Copy link

nandac commented Nov 3, 2021

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

cdktf & Language Versions

cdktf-cli version: 0.7.0
Terraform version: 0.15.5
Python version: 3.9

Affected Resource(s)

cdktf convert command fails with the error Maximum call stack size exceeded whatever the file used maybe. Downgrading the CLI to 0.6.4 did not help. Upgrading to the latest development version also did not help.

Debug Output

https://gist.github.com/nandac/7f7522a6e0de22ea01f6f5428943c7df

Expected Behavior

Converted CDKTF content should either be available in the file provided or printed to stdout.

Actual Behavior

Errors out with Maximum call stack size exceeded with output provided in the gist.

Steps to Reproduce

Assuming versions.tf contains the following content:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }

    external = {
      source  = "hashicorp/external"
      version = "~> 2.0"
    }

    local = {
      source  = "hashicorp/local"
      version = "~> 2.0"
    }

    null = {
      source  = "hashicorp/null"
      version = "~> 3.0"
    }

    spotinst = {
      source  = "spotinst/spotinst"
      version = "~> 1.0"
    }

    template = {
      source  = "hashicorp/template"
      version = "~> 2.2"
    }
  }

  required_version = "0.15.5"
}

On the console I tried:
cat versions.tf | cdktf convert --provider hashicorp/aws --language python

Important Factoids

References

  • #0000
@nandac nandac added bug Something isn't working new Un-triaged issue labels Nov 3, 2021
@ansgarm ansgarm added confirmed independently reproduced by an engineer on the team feature/convert and removed new Un-triaged issue labels Nov 4, 2021
@ansgarm ansgarm self-assigned this Nov 4, 2021
@ansgarm
Copy link
Member

ansgarm commented Nov 4, 2021

Hi @nandac!
Thank you for the reproduction steps, I could reproduce the issue. It seems that findFileAboveCwd does not properly break the recursion if no cdktf.json file could be found.

A workaround would be to run the convert command in a directory that contains a cdktf.json file. It is only used to determine the Terraform providers used – so it won't affect the output from convert if no providers are specified in the cdktf.json.

I will also create a PR with a fix, but that would need to be released first (or merged if you want to use the pre-release build).

ansgarm added a commit that referenced this issue Nov 4, 2021
…unning convert

`path.resolve(rootPath, ..)` will return rootPath if there's no more parent directory.
This caused an infinite loop ending in `RangeError: Maximum call stack size exceeded`.

Resolves #1247
ansgarm added a commit that referenced this issue Nov 4, 2021
…unning convert

`path.resolve(rootPath, ..)` will return rootPath if there's no more parent directory.
This caused an infinite loop ending in `RangeError: Maximum call stack size exceeded`.

Resolves #1247
ansgarm added a commit that referenced this issue Nov 4, 2021
…unning convert

`path.resolve(rootPath, ..)` will return rootPath if there's no more parent directory.
This caused an infinite loop ending in `RangeError: Maximum call stack size exceeded`.

Resolves #1247
@nandac
Copy link
Author

nandac commented Nov 4, 2021 via email

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

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 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working confirmed independently reproduced by an engineer on the team feature/convert
Projects
None yet
2 participants