Skip to content

fix(#82): handle provider version as list in .terraform.lock.hcl #83

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

harlemtraveler
Copy link

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!

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