-
Notifications
You must be signed in to change notification settings - Fork 15
Fix improper diagnostic usage across multiple services #832
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
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 standardizes diagnostic usage by improving error messages with context, ensuring proper error propagation, and handling previously ignored errors across multiple services.
- Enhances diagnostics in connection shares and environment settings with accurate context and type checks
- Refactors DLP policy helpers to return errors and updates Create/Update flows accordingly
- Adds missing error handling for object value conversion in data records
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
internal/services/connection/datasource_connection_shares.go | Added detailed context to the connection shares error message |
internal/services/dlp_policy/helpers.go | Refactored helper functions to return errors and propagate diagnostics |
internal/services/dlp_policy/resource_dlp_policy.go | Updated Create/Update methods to handle helper errors before assignment |
internal/services/data_record/resource_data_record.go | Added error check and early return for ObjectValue failures |
internal/services/environment_settings/resources_environment_settings.go | Added ProviderData type assertion and improved nil-client diagnostic |
.changes/unreleased/fixed-20250605-072531.yaml | Documented all fixed issues in the changelog |
Comments suppressed due to low confidence (2)
internal/services/dlp_policy/helpers.go:191
- Update the function documentation and comments to reflect the new error return value, so callers are aware this helper can now return an error and must handle it.
func convertToDlpConnectorGroup(ctx context.Context, diags diag.Diagnostics, classification string, connectorsAttr basetypes.SetValue) (dlpConnectorGroupsModelDto, error) {
internal/services/environment_settings/resources_environment_settings.go:314
- [nitpick] Consider updating the message to use consistent casing for 'API' (e.g., 'Provider client API is nil') to align with common terminology.
"Provider client Api is nil. Please report this issue to the provider developers.",
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
This PR addresses several diagnostic usage issues that were impacting error handling and debugging capabilities across the Terraform Provider for Power Platform.
Issues Fixed
1. Missing Error Detail in Connection Shares API Error
Location:
internal/services/connection/datasource_connection_shares.go
Before:
After:
2. Improper Error Propagation in DLP Policy Helper Functions
Location:
internal/services/dlp_policy/helpers.go
The helper functions
convertToDlpConnectorGroup
andconvertToDlpCustomConnectorUrlPatternsDefinition
were adding errors to diagnostics but not properly returning early or propagating errors, which could lead to partially incorrect data being created.Before:
After:
3. Ignored Error in Data Record Column Conversion
Location:
internal/services/data_record/resource_data_record.go
Before:
After:
4. Misleading Error Message in Environment Settings
Location:
internal/services/environment_settings/resources_environment_settings.go
The code was missing type assertion checks and had an incorrect error message referring to
*http.Client
instead of the expected*api.ProviderClient
.Before:
After:
Impact
These changes improve:
Testing
Fixes #816.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://168.63.129.16:80/machine/
/usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 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.