-
Notifications
You must be signed in to change notification settings - Fork 3
fix: resolve state upgrade error for connections with rules (issue #191) #192
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
Conversation
Users upgrading from v2.0 to v2.1+ encountered a "Value Conversion Error" with message "mismatch between struct and object: Struct defines fields not found in object: deduplicate_rule" when configuring connections with rules. Root cause: The state upgrader was trying to unmarshal V0 state (which lacks deduplicate_rule) into the current connectionResourceModel (which expects it). Changes: - Add V0-compatible model structs for state upgrade compatibility - Update state upgrader to use V0 models and convert to current models - Add conversion helper functions for V0 to current model migration - Update getRulePriority to handle DeduplicateRule - Add unit tests replicating issue #191 exactly - Add acceptance test for V0 to V1 state migration - Update migration guide with troubleshooting section Fixes #191
There was a problem hiding this 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 issue #191 where users upgrading from Hookdeck Terraform Provider v2.0 to v2.1+ encountered a "Value Conversion Error" stating "mismatch between struct and object: Struct defines fields not found in object: deduplicate_rule" when configuring connections with rules.
Changes:
- Added V0-compatible model structs (connectionResourceModelV0, ruleV0, etc.) that match the schema before deduplicate_rule and response_status_codes were added
- Updated state upgrader to use V0 models when reading old state, then convert to current models
- Added conversion functions (convertV0ToCurrent, convertRulesV0ToCurrent, etc.) to properly migrate state from V0 to V1 format
- Updated getRulePriority to include DeduplicateRule in the correct position (priority 3)
- Added comprehensive unit tests for the conversion logic
- Added acceptance test verifying the issue #191 configuration works
- Updated migration guide with troubleshooting section and workarounds
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/provider/connection/model.go | Added V0 model structs (connectionResourceModelV0, ruleV0, filterRuleV0, filterRulePropertyV0, retryRuleV0) that match the pre-v2.1 schema without deduplicate_rule and response_status_codes |
| internal/provider/connection/stateupgrade.go | Updated state upgrader to use V0 models when reading old state and added conversion functions to migrate V0 state to current format, including proper handling of new fields |
| internal/provider/connection/stateupgrade_test.go | Added comprehensive unit tests for V0 to V1 conversion covering retry-only rules, multiple rules, empty rules, transform rules, and filter rule property conversion |
| internal/provider/connection/resource_test.go | Added acceptance test TestAccConnectionResource_Issue191 that validates the exact configuration from issue #191 works correctly |
| internal/provider/connection/testdata/issue_191_retry_only.tf | Added test configuration file replicating the exact setup from issue #191 |
| templates/guides/v2.0-to-v2.1-migration.md | Added troubleshooting section documenting the error and providing resolution steps including workaround for users who cannot immediately upgrade |
| docs/guides/v2.0-to-v2.1-migration.md | Mirror of template file with same troubleshooting documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@leggetter I've opened a new pull request, #193, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: leggetter <[email protected]>
Add clarifying comment to acceptance test for issue #191
Users upgrading from v2.0 to v2.1+ encountered a "Value Conversion Error"
with message "mismatch between struct and object: Struct defines fields
not found in object: deduplicate_rule" when configuring connections with
rules.
Root cause: The state upgrader was trying to unmarshal V0 state (which
lacks deduplicate_rule) into the current connectionResourceModel (which
expects it).
Changes:
Fixes #191