Skip to content

Conversation

@harlemtraveler
Copy link
Contributor

Description

This PR resolves a TypeError that occurs when .terraform.lock.hcl contains the version field as a string, but recent versions of Terraform may emit the value as a list. This causes a TypeError within the get_provider_version_from_lock_file() function.

.terraform.lock.hcl content

provider "registry.terraform.io/hashicorp/aws" {
  version = "5.100.0"

Error returned from /bin/tflocal

TypeError: expected string or bytes-like object, got 'list'

Fix

This fix checks for a list and safely parses the first element if necessary.

@harlemtraveler harlemtraveler changed the title fix(tflocal): handle provider version as list in .terraform.lock.hcl fix(#82): handle provider version as list in .terraform.lock.hcl Jun 21, 2025
@bentsku bentsku self-requested a review June 30, 2025 14:30
@bentsku
Copy link
Contributor

bentsku commented Jul 1, 2025

Hello @harlemtraveler and thanks for a lot for the contribution! It seems the CI is failing with the change, but I'm not too sure why.
Could you please share how to reproduce the issue so maybe we could add a test case for it, or that I could reproduce the issue myself?
I've tried running the CI on the main branch and it passed, so I suppose this change is breaking something but not too sure why without a reproducer. Thanks!

edit: I'm currently trying it out locally, and trying to run the CI again to see if it's a real issue. Will keep you updated 👍

CI is now green, I wonder what happened 😄

Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this seems like a fair change! Thanks for providing a fix, and welcome to the contributors! 🙏

@bentsku bentsku merged commit 0ea14b3 into localstack:main Jul 3, 2025
3 of 6 checks passed
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