OpenSearch.Net Method not found issue

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Server: OpenSearch Version=“1.3”
Client: .Net OpenSearch.Client Version=“1.3.0”
.Net version: .Net 6.0

Describe the issue:
Hi, I have faced issue while following the startup guide for AWS SigV4 support for OpenSearch.

        Console.WriteLine("Os client");
        var connection = new AwsSigV4HttpConnection();
        var config = new ConnectionSettings(new SingleNodeConnectionPool(uri), connection)
            .DefaultIndex("people")
            .DisableDirectStreaming();
        var client = new OpenSearchClient(config);

        Console.WriteLine("Start requests");
        var response = client.Index(person, i => i.Index("persons"));

On client.Index() line i receive this error:

Method not found: 'System.String Amazon.Util.AWSSDKUtils.CanonicalizeResourcePathV2(System.Uri, System.String, Boolean, System.Collections.Generic.IDictionary`2<System.String,System.String>)'.

I have tried to change versions of OpenSearch.Client and OpenSearch.Net.Auth.AwsSigV4 but it didn’t fix the issue.

Configuration:
I’m running this code in AWS Lambda with such packages:

<ItemGroup>
    <PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
    <PackageReference Include="OpenSearch.Client" Version="1.3.0" />
    <PackageReference Include="OpenSearch.Net.Auth.AwsSigV4" Version="1.3.0" />
  </ItemGroup>

Relevant Logs or Screenshots:
Error log:

	OpenSearch.Net.UnexpectedOpenSearchClientException: Method not found: 'System.String Amazon.Util.AWSSDKUtils.CanonicalizeResourcePathV2(System.Uri, System.String, Boolean, System.Collections.Generic.IDictionary`2<System.String,System.String>)'.
 ---> System.MissingMethodException: Method not found: 'System.String Amazon.Util.AWSSDKUtils.CanonicalizeResourcePathV2(System.Uri, System.String, Boolean, System.Collections.Generic.IDictionary`2<System.String,System.String>)'.
   at OpenSearch.Net.Auth.AwsSigV4.CanonicalRequest.From(HttpRequestMessage request, ImmutableCredentials credentials, DateTime signingTime)
   at OpenSearch.Net.Auth.AwsSigV4.AwsSigV4Util.SignRequest(HttpRequestMessage request, ImmutableCredentials credentials, RegionEndpoint region, DateTime signingTime, String service)
   at OpenSearch.Net.Auth.AwsSigV4.AwsSigV4HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

(i can add full log on request)

Hi @Denied5,

This error would generally be caused by an old AWSSDK.Core version being pulled in but I don’t immediately see why that would happen with the dependencies you have listed. Would you be able to please run dotnet list package --include-transitive from within your project that is being deployed to Lambda and copy the output here?

Please also verify that the artifact being deployed contains AWSSDK.Core.dll.

Further, if possible, a complete minimal reproducing project would be helpful for understanding.

Thanks!

Hi @xtansia, thanks for your help!

Project ‘***’ has the following package references
[net6.0]:
Top-level Package Requested Resolved

Amazon.Lambda.Core 2.1.0 2.1.0
Amazon.Lambda.Serialization.SystemTextJson 2.3.1 2.3.1
AWSSDK.SecurityToken 3.7.103.16 3.7.103.16
OpenSearch.Client 1.3.0 1.3.0
OpenSearch.Net.Auth.AwsSigV4 1.3.0 1.3.0

Transitive Package Resolved

AWSSDK.Core 3.7.107.8
Microsoft.CSharp 4.6.0
OpenSearch.Net 1.3.0
System.Buffers 4.5.1
System.Diagnostics.DiagnosticSource 6.0.0
System.Runtime.CompilerServices.Unsafe 6.0.0

During lambda deployment i can notice AWSSDK.Core.dll in dependencies:

The problem was in how lambda tool works with nugets. Previously I experimented with a newer version of a nuget package and it was saved in a bin folder, Lambda tool collects the latest versions of packages from bin folder.
So for me solution was to remove bin and obj folders and publish lambda again

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.