Skip to content

Incorrect quoting when parsing list of strings in a tfvars file #286

Closed

Description

@adam-security

Describe the bug

With the release of version 8.x lists of strings are now double quoted and essentially '"x"' instead of 'x'. This behavior changed this morning in corelation with the 8.10 release. The script was unchanged for 3 years. and yeah... I should have pinned the version of this lib.

I'll harden for it if this is expected but it kind of caused an outage this morning... and I should have pinned the version

Software:

  • OS: [macOS / Linux] (my laptop and github actions runner
  • Python version 3.13 (mac) and what ever the standard GHA runner uses
  • python-hcl2 version 8.10

Snippet of HCL2 code causing the unexpected behaviour:

In an tfvars file we have

members = [
  "list",
  "of",
  "user",
  "names"
]

and are essentially doing

with open("../organization/org.auto.tfvars", "r") as file_in:
  data = hcl2.load(file_in)

# we have multiple lists but though I would give a fuller context, all 3 lists are basically the above
desired_members = list(set(data['members']) | set(data['admins']) | set(data.get('ncsu_members', [])))

When the new version released this morning, the desired_members list became

['"list"', '"of"', '"user"', '"names"']

When simplifying that set union to a raw 'only hcl2.load` , it's still an issue

data['members']
['"list"', '"of"', '"user"', '"names";]

note the double quotes in the single quotes.

This broke some audit automation we had .... which admittedly should have had some more 'too much change protection' this morning .

Expected behavior

The previous behavior with a single set of quotes inline with pep8 guidelines "foo" instead of "'"foo"' (or single ticks... I don't remember the pep8 preference)

Activity

  1. added
    bug
    on Apr 7, 2026
  2. changed the title [-]Incorrect quoting in a tfvars file[/-] [+]Incorrect quoting when parsing list of strings in a tfvars file[/+] on Apr 7, 2026
  3. kkozik-amplify commented on Apr 7, 2026

    @kkozik-amplify
    Collaborator

    Hi @adam-security This is the new expected behavior. However, it can be controlled with this option

  4. removed
    bug
    on Apr 7, 2026
  5. adam-security commented on Apr 7, 2026

    @adam-security
    Author

    Hi @adam-security This is the new expected behavior. However, it can be controlled with this option

    Cool, as long as it's expected and thanks for pointing that out....It caused a P1 fire this morning but, I also should have pinned this when I wrote the cleaner script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions