-
Notifications
You must be signed in to change notification settings - Fork 15
Fix context and defer issues in Configure methods #834
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>
Co-authored-by: mawasile <50197777+mawasile@users.noreply.github.com>
internal/services/admin_management_application/resource_admin_management_application.go
Fixed
Show fixed
Hide fixed
internal/services/application/resource_environment_application_package_install.go
Fixed
Show fixed
Hide fixed
internal/services/tenant_isolation_policy/resource_tenant_isolation_policy.go
Fixed
Show fixed
Hide fixed
…local variable Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@copilot run linter and fix issues |
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.
This is not a good change to reorder. We lose tracing on this.
@mawasile we should close this PR without merging. This is not a good change and makes our tracing worse. |
Linting passed with no issues found.
You're absolutely right about losing tracing. I've reverted all Configure methods back to the original pattern where |
…xt before nil check Co-authored-by: mattdot <266258+mattdot@users.noreply.github.com>
This PR fixes context handling and defer statement issues in resource Configure methods across the Terraform Provider for Power Platform.
Problem
The issue was in the
Configure
methods of all resources wherehelpers.EnterRequestContext
was being called and defer cleanup was being registered even whenreq.ProviderData
wasnil
, leading to unnecessary resource allocation and cleanup registration for early returns.Before (problematic pattern):
Solution
Reordered the logic to check for
nil
ProviderData before creating any context or timeout resources:After (fixed pattern):
Changes Made
Configure
methods across all services in the providerBenefits
Testing
Fixes #819.
💡 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.