Skip to content
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

tflint: Fix panic when encoding empty body #1118

Merged
merged 1 commit into from
May 5, 2021

Conversation

wata727
Copy link
Member

@wata727 wata727 commented May 4, 2021

Fixes terraform-linters/tflint-plugin-sdk#115

When encoding HCL bodies for sending to a plugin, the range of blocks is calculated from the contents of the body. However, if the body is empty, an empty range will be the return value of the HCLBodyRange func because there is no target range. Since the empty range doesn't have a filename, panic will occur when slicing source code bytes from the range:

Config: configRange.SliceBytes(s.runner.File(configRange.Filename).Bytes),

This PR avoids this panic by always setting the filename, even if the body is empty.

@wata727 wata727 merged commit a7a1b4c into master May 5, 2021
@wata727 wata727 deleted the set_filename_when_empty_body_only branch May 5, 2021 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation violation for empty data source
1 participant