-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Print retryLogHook messages to stderr #35159
Comments
I'm currently using a quick and dirty workaround: def extract_json_objects(text, decoder=JSONDecoder()):
"""
Find JSON objects in text, and yield the decoded JSON data
Does not attempt to look for JSON arrays, text, or other JSON types outside
of a parent JSON object.
Derived from https://stackoverflow.com/a/54235803
This is useful for handling JSON objects embedded in a string, such as
when this bug pollutes the output:
https://github.com/hashicorp/terraform/issues/35159
"""
pos = 0
while True:
match = text.find("{", pos)
if match == -1:
break
try:
result, index = decoder.raw_decode(text[match:])
yield result
pos = match + index
except ValueError:
pos = match + 1 |
Terraform has [a bug](hashicorp/terraform#35159) where the JSON output of `terraform output -json` can be polluted by error messages. This is a workaround to parse the output json properly.
Any updates on this at all. We are seeing the issue with our Terraform Cloud workflows as well. |
Hey @ben-z, thank you for reporting this. It seems like the initial and repeated retry error log messages are not rendered through a view yet, which causes them to default to a human-readable output. Ideally, there should always be a I'll be picking up this issue and will share more information there as soon as it becomes available. Thanks again! |
Terraform Version
Terraform Configuration Files
Debug Output
Not relevant
Expected Behavior
terraform -output json
should output only JSON.Actual Behavior
The output is not pure json. It contains some error messages from intermittent (retriable) errors.
These are the culprit messages:
terraform/internal/command/views/cloud.go
Lines 51 to 56 in dc3a040
This makes it nontrivial for downstream applications to parse the output.
Steps to Reproduce
terraform -output json
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: