[sdk/nodejs] Fix provider for resource methods #13796
Merged
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.
The
Resource
class in the Node.js SDK has the following internal property:When a resource is created, the provider specified for the resource is stored in this property. If it is set, it is passed along in the
Call
request when a method is called on the resource.Prior to #13282, the property was only set for custom resources in
Resource
's constructor:With #13282, it was changed to also store the value for remote components:
This regressed the behavior when calling a method on a remote component that had an explicit provider that wasn't the component provider, but some other provider (e.g. AWS provider) specified as:
The
awsProvider
was being stored inResource.__prov
, and when making the method call on the resource, it would try to invokeCall
on the AWS provider, rather than calling the remote component provider'sCall
, which resulted in an error.Note that specifying the AWS provider using the more verbose
providers: [awsProvider]
works around the issue.The fix is to only set
__prov
if the provider's package is the same as the resource's package. Otherwise, don't set it, because the user is specifying a provider with theprovider: awsProvider
syntax as shorthand forproviders: [awsProvider]
.Fixes #13777