You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The literal string "string" is incorrectly quoted #251
When deserializing a property that assigns the literal value string to a property, it is incorrectly quoted.
A clear and concise description of what the bug is.
Software:
OS: Linux
Python version 3.11
python-hcl2 version 7.3.1
Snippet of HCL2 code causing the unexpected behaviour:
variable"octopus_space_id" {
type=stringnullable=falsesensitive=falsedescription="The ID of the Octopus space to populate."
}
Expected behavior
The following script should produce output with an unquoted string value:
importhcl2hcl="""variable "octopus_space_id" { type = string nullable = false sensitive = false description = "The ID of the Octopus space to populate."}"""parsed_config=hcl2.loads(hcl, with_meta=True)
example_ast=hcl2.reverse_transform(parsed_config)
converted_hcl=hcl2.writes(example_ast)
print(converted_hcl)
The result of this script is this:
variable "octopus_space_id" {
type = "string"
nullable = false
sensitive = false
description = "The ID of the Octopus space to populate."
}
Terraform does not accept this output as the type must be an unquoted value.
Activity
kkozik-amplify commentedon Apr 7, 2026
Fixed in the latest release:
https://github.com/amplify-education/python-hcl2/releases/tag/v8.1.0