-
Notifications
You must be signed in to change notification settings - Fork 15
Fix error handling issues in environment group services #807
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
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
@copilot please run the precommit tools and run changie to report change log |
…vices Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
Completed both requested tasks: ✅ Precommit tools: Ran linting (0 issues), unit tests (environment group services pass), and build (successful) ✅ Changie changelog: Created changelog entry for error handling fixes referencing issue #806 See commit fb53e9d for the changelog entry. |
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 improves error handling in the Power Platform Terraform provider's environment group services by adding additional context to errors and ensuring consistent error reporting.
- Enhanced error wrapping with fmt.Errorf in environment group create, update, get, and delete methods.
- Fixed error handling when dealing with HTTP no-content responses and improper pointer dereferencing in resource state functions.
- Updated error messages in the rule set configure and API methods for clarity.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
internal/services/environment_groups/api_environment_group.go | Added contextual error wrapping in create, update, get, and remove methods. |
internal/services/environment_group_rule_set/resource_environment_group_rule_set.go | Corrected error message and pointer usage in state set, and updated configure error messaging. |
internal/services/environment_group_rule_set/api_environment_group_rule_set.go | Improved error wrapping for tenant retrieval, GET, create, update, and delete methods with clearer messages. |
.changes/unreleased/fix_error_handling_environment_groups.yaml | Updated changelog file to reflect improved error handling. |
This PR addresses multiple error handling issues found in the Power Platform Terraform provider's environment group services, improving error context, debugging capabilities, and overall reliability.
Issues Fixed
1. Missing Error Wrapping with Context
Files:
internal/services/environment_groups/api_environment_group.go
Added proper error wrapping in all API methods to provide better context for debugging:
2. Error Value Usage After Control Flow
Files:
internal/services/environment_group_rule_set/api_environment_group_rule_set.go
Fixed incorrect error wrapping when handling
http.StatusNoContent
responses:3. Silent Failure in Delete Method
Files:
internal/services/environment_group_rule_set/api_environment_group_rule_set.go
Improved error handling in the delete method to ensure proper error context:
4. Improved Parameter Length Check Error Message
Files:
internal/services/environment_group_rule_set/api_environment_group_rule_set.go
Enhanced error message clarity and added explanatory comment:
5. Incorrect Error Message in Configure Method
Files:
internal/services/environment_group_rule_set/resource_environment_group_rule_set.go
Fixed misleading error message to reflect the actual expected type:
6. Pointer Model Usage in State Management
Files:
internal/services/environment_group_rule_set/resource_environment_group_rule_set.go
Fixed incorrect pointer dereferencing in the Create method:
Testing
Impact
These changes improve:
Fixes #806.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.