Skip to content

Fix Set Encoding + Field Names on Encoding Crashes#15

Merged
hfern merged 2 commits into
masterfrom
hgf/foreach_fix
Sep 17, 2025
Merged

Fix Set Encoding + Field Names on Encoding Crashes#15
hfern merged 2 commits into
masterfrom
hgf/foreach_fix

Conversation

@hfern
Copy link
Copy Markdown
Owner

@hfern hfern commented Sep 5, 2025

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_equal function implemented by Set. It was not expecting Unknown.

I went back and forth a couple of times on whether semantically_equal should 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.

Copy link
Copy Markdown

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 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 Unknown planned 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.

Comment thread tf/provider.py
Comment thread tf/tests/test_provider.py
@hfern hfern merged commit b815aa8 into master Sep 17, 2025
6 checks passed
@hfern hfern deleted the hgf/foreach_fix branch September 17, 2025 00:44
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.

3 participants