Code Monkey home page Code Monkey logo

Comments (8)

philasmar avatar philasmar commented on June 28, 2024 2

We have released a fix for this bug today.

Please use the new package versions and try again:
AWSSDK.Core: 3.7.304.19
AWSSDK.DynamoDBv2: 3.7.303.25

from aws-sdk-net.

bhoradc avatar bhoradc commented on June 28, 2024 1

Hello @alvaromon,

Thank you for reporting the issue. Using below code sample I am able to reproduce the InvalidOperationException that you mentioned.

using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;

namespace DDB_LoadAsync_3343
{
    public class Program
    {
        public static async Task Main()
        {
            Amazon.AWSConfigs.LoggingConfig.LogResponses = Amazon.ResponseLoggingOption.Always
            Amazon.AWSConfigs.LoggingConfig.LogTo = Amazon.LoggingOptions.Console;
            Amazon.AWSConfigs.AddTraceListener("Amazon", new System.Diagnostics.ConsoleTraceListener());

            var client = new AmazonDynamoDBClient();
            DynamoDBContext context = new DynamoDBContext(client);

            var d = new MyClass { Number = "3.7.302", Addresses = new List<string>() { "add1", "add2" } };

            await context.SaveAsync<MyClass>(d);

            var loaded = await context.LoadAsync<MyClass>(d.Number, d.Addresses);
        }

        private class BaseClass
        {
            public string Number { get; set; }
            public IList<string> Addresses { get; set; }
        }

        [DynamoDBTable("OverrideBase")]
        private class MyClass : BaseClass
        {
            [DynamoDBHashKey]
            public new string Number
            {
                get => base.Number;
                set => base.Number = value;
            }
            public new List<string>? Addresses { get; set; }  
        }
    }
}

I am able to reliably reproduce this error with AWSSDK.DynamoDBv2 3.7.300 onwards. I will review this issue with the .NET SDK team to investigate it further. We shall keep you posted.

Hi @YuriiMocherniuk,

The error you mentioned looks similar. Can you provide code sample for your use-case? Also, I don't see the package version for AWSSDK.DynamoDBv2 in the screenshot that you shared.

Regards,
Chaitanya

from aws-sdk-net.

philasmar avatar philasmar commented on June 28, 2024 1

We are currently working on a fix for this issue.

from aws-sdk-net.

alvaromon avatar alvaromon commented on June 28, 2024 1

thank you to the team. That was very fast!

from aws-sdk-net.

YuriiMocherniuk avatar YuriiMocherniuk commented on June 28, 2024

I'm having a similar issue, also on .NET 8:

System.InvalidOperationException: Dictionary already contains item with key Usage
   at Amazon.Util.Internal.InternalSDKUtils.AddToDictionary[TKey,TValue](Dictionary`2 dictionary, TKey key, TValue value)
   at Amazon.DynamoDBv2.DataModel.StorageConfig.GetMembersDictionary(Type type)
   at Amazon.DynamoDBv2.DataModel.StorageConfig..ctor(Type targetType)
   at Amazon.DynamoDBv2.DataModel.ItemStorageConfig..ctor(Type targetType)
   at Amazon.DynamoDBv2.DataModel.ItemStorageConfigCache.CreateStorageConfig(Type baseType, String actualTableName, DynamoDBFlatConfig flatConfig)
   at Amazon.DynamoDBv2.DataModel.ItemStorageConfigCache.GetConfig(Type type, DynamoDBFlatConfig flatConfig, Boolean conversionOnly)
   at Amazon.DynamoDBv2.DataModel.BatchWrite`1..ctor(DynamoDBContext context, Type valuesType, DynamoDBFlatConfig config)
   at Amazon.DynamoDBv2.DataModel.DynamoDBContext.CreateBatchWrite[T](DynamoDBOperationConfig operationConfig)

Do you think its origin is the same? Previously before .NET 8 and AWS NuGet packages upgrade we haven't been facing such problem.

from aws-sdk-net.

YuriiMocherniuk avatar YuriiMocherniuk commented on June 28, 2024

Extra information: the issue started to occur after the following NuGet package upgrade:
image

from aws-sdk-net.

YuriiMocherniuk avatar YuriiMocherniuk commented on June 28, 2024

Hi @bhoradc,

Actually, we had several NuGet packages referenced in other projects and the AWSSDK.Core, AWSSDK.DynamoDBv2 packages probably got referenced here as transitive dependencies (they haven't been referenced in this case explicitly).

As for the code that throws exception, overall it looks as follows:
var batch = context.CreateBatchWrite<UsageItem>();
context member here has DynamoDBContext type.

In this case there's Usage property present on both UsageItem class and its parent class. The type differs as in your example with Addresses property and we also use new keyword in the child class.

I hope this information helps with issue resolution.

Regards,
Yura

from aws-sdk-net.

github-actions avatar github-actions commented on June 28, 2024

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

from aws-sdk-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.