Fix Set Encoding + Field Names on Encoding Crashes#15
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug where set-typed fields without default or specified values would crash during resource creation due to an encoding issue where Unknown values were incorrectly passed to custom semantically_equal functions.
- Adds handling for
Unknownplanned values in the encoding logic to prevent crashes - Introduces exception enrichment to provide better error messages when encoding failures occur
- Adds comprehensive test coverage for the bug scenario and error handling
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tf/provider.py | Core fix for Unknown value handling and exception enrichment for encoding errors |
| tf/tests/test_provider.py | Test cases for the bug scenario and a custom Set type for testing |
| e2e/mathprovider/mathprovider/test_provider.py | Additional e2e test for for_each functionality |
| CHANGELOG.md | Documentation of the bug fix and new error reporting feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
ralphie0112358
approved these changes
Sep 17, 2025
4f1c746 to
4ffb05e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a bug where set-typed fields without default or specified values would crash on creation. This is because of an encoding bug: we passed in Unknown to the custom
semantically_equalfunction implemented by Set. It was not expecting Unknown.I went back and forth a couple of times on whether
semantically_equalshould be Unknown-aware or not. I am still not really sure. I ended up obviating the need to make a decision on that because the specific case that caused this had a broader solution: If the planned value was Unknown then we should just accept whatever the new value is. It can't be worse than Unknown.I also added exception enrichment if this happens again and the provider framework catastrophically crashes. Now it will tell you specifically what field led to the exception.