Fix nil-pointer dereference in NewFilterResourceModel when API returns nil CaseSensitive#653
Open
see-cool wants to merge 3 commits into
Open
Fix nil-pointer dereference in NewFilterResourceModel when API returns nil CaseSensitive#653see-cool wants to merge 3 commits into
see-cool wants to merge 3 commits into
Conversation
…s nil CaseSensitive `terraform plan` panics with a nil-pointer dereference reading any `opslevel_filter` whose state holds a case_sensitive value for a predicate that the API returns as nil. This blocks all filter operations on workspaces upgrading from older provider versions (0.8.x), since the old schema stored case_sensitive on every predicate regardless of whether the predicate type uses it. This commit adds a test that will fail when run. In a second PR, I will then introduce the patch that will cause the test to pass. In addition to writing these test cases, I have used the patched code locally on my machine to run a `terraform plan` and it indeed succeeds after patching.
bewinsnw
approved these changes
Jun 10, 2026
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.
Resolves #
Problem
terraform planpanics with a nil-pointer dereference reading anyopslevel_filterwhose state holds a case_sensitive value for a predicate that the API returns as nil.This blocks all filter operations on workspaces upgrading from older provider versions (0.8.x), since the old schema stored case_sensitive on every predicate regardless of whether the predicate type uses it.
Solution
Add a guard against dereferencing.
opslevelPredicate.CaseSensitive != nilshould be enough. When the API returns nil, it'll ultimately set the model field toBoolNull())which represents that the value is unset.The first commit adds a test that will fail when run, demonstrating the latent bug.
In a second commit, we introduce the patch that will fix the code and make the test pass. In addition to writing these test cases, I have used the patched code locally on my machine to run a
terraform planand it indeed succeeds after patching.Checklist