Skip to content

Fix: Error during templating due to inconsistent elements order in array#22

Open
pcortada-te wants to merge 1 commit intomainfrom
Error-during-templating,-inconnsistrent-array-order
Open

Fix: Error during templating due to inconsistent elements order in array#22
pcortada-te wants to merge 1 commit intomainfrom
Error-during-templating,-inconnsistrent-array-order

Conversation

@pcortada-te
Copy link
Copy Markdown
Collaborator

Description

I was getting

Traceback (most recent call last):
...
  File "/home/atlantis/.atlantis/repos/thousandeyes/thousandeyes-aws-infrastructure/22840/default/stacks/eks-resources/layers/stg-fra1_eks1/.venv/lib/python3.13/site-packages/stacks/filters/lookup.py", line 40, in terraform_init_headless
    helpers.json_write({"terraform": [{"backend": code["terraform"][0]["backend"]}]}, remote_ctx.universe_file)
                                                  ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'backend' code["terraform"] 

as `code[“terraform”]`` has 2 elements and backend is in the 2nd one [1], not the first [0]. I assume a change in python-hcl2 lib may have caused a change in the output(?)

The fix is a quick search for the correct block, I focused in readibility, it can be more pythonic but it gets confusing.

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change
  • Refactor
  • Documentation
  • Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • [N/A ] Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

@pcortada-te pcortada-te requested a review from a team as a code owner November 24, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants