Skip to content

writes produces incorrect hcl: omits quotes around in map keys containing / #236

Closed

Description

@esciara

Using version 7.2.1

The following Python code:

import hcl2

my_hcl = """toto = {
    "john/doh" = {}
} 
"""

tf_vars = hcl2.loads(my_hcl)
hcl2.writes(hcl2.reverse_transform(tf_vars))

Produces:

'toto = {\n  john/doh = {}\n}\n'

hence not keeping the quotes on"john/doh" and generating incorrect hcl.

Activity

  1. esciara commented on Jun 13, 2025

    @esciara
    Author

    I guess it should be the same for other special characters requiring double quotes.

  2. added
    deserialization
    bug
    on Jun 17, 2025
  3. added
    serialization
    on Jul 4, 2025
  4. lijok commented on Jul 31, 2025

    @lijok

    Running into the same issue here

  5. kkozik-amplify commented on Apr 7, 2026

    @kkozik-amplify
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugdeserializationserialization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions