Skip to content

Conversation

@gigovich
Copy link
Contributor

@gigovich gigovich commented Dec 3, 2025

The ToTerraformValue method was incorrectly returning a known empty string when the rawJsonValue was in an unknown or null state. This caused validation to fail during terraform plan when script values contained computed/unknown values (e.g., from random_* resources or other computed attributes).

The ToTerraformValue method was incorrectly returning a known empty string
when the rawJsonValue was in an unknown or null state. This caused validation
to fail during terraform plan when script values contained computed/unknown
values (e.g., from random_* resources or other computed attributes).
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in the RawJsonType.ToTerraformValue method that was incorrectly handling unknown and null values, causing them to be treated as known empty strings. This fix enables proper handling of computed values (e.g., from random_* resources) in script attributes during Terraform plan operations.

Key Changes

  • Added null/unknown state checks in RawJsonType.ToTerraformValue to return proper tftypes.Value representations
  • Implemented comprehensive test coverage for the ToTerraformValue method
  • Refactored scriptValidator to use ValueString() instead of the convoluted bytes.NewBufferString().String().Bytes() pattern

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/provider/type_rawjson.go Added null and unknown state handling in ToTerraformValue method to properly return tftypes.UnknownValue and nil respectively
internal/provider/type_rawjson_test.go Added comprehensive test coverage for ToTerraformValue with known, unknown, and null value test cases
internal/provider/attr_script.go Simplified JSON validation by using ValueString() directly and removed unused bytes import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants