MLAPI NetworkedDictionary same key when behavior created from client, with IsServer Bool

Hi.
I’m not understanding why NetworkDictionary is exploding.

This code that is in a component on the spawned object:
Simple Server only list add

public class ResourceBehavior : NetworkedBehaviour
    {
       private NetworkedDictionary<string, int> m_NetIntResource = new NetworkedDictionary<string, int>();

             public override void NetworkStart()
             {
                      base.NetworkStart();
                      if(IsServer)
                      {
                            m_NetIntResource.Add("Test", 0);
                      }
            }
       }

Works fine when objects are spawned from the host. However when the client sends a server a message to spawn the same object using this function:

Server RPC

[ServerRPC]
        private void Server_RequestAddActorToEvent(int objectToSpawnID, Vector3 position, Quaternion rotation)
        {
            RecordContent actor = Database.Instance.GetRecordActor(objectToSpawnID);

            //ServerCreateActor.
#if GBSERVER
            GamePlayer.GetLocal.CurrentEditModeEncounter.Value.Edit_AddActor(actor as RecordActor, position, rotation);
        
#endif
        }

The client gets the following error. I don’t see how I’m adding a key twice. It should ONLY be adding on the server. I’ve put logs in and far as I can tell nothing I’m doing is adding this key twice. What am I missing?

Call Stack

ArgumentException: An item with the same key has already been added. Key: Test
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <9577ac7a62ef43179789031239ba8798>:0)
MLAPI.NetworkedVar.Collections.NetworkedDictionary`2[TKey,TValue].ReadDelta (System.IO.Stream stream, System.Boolean keepDirtyDelta) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkedBehaviour.HandleNetworkedVarDeltas (System.Collections.Generic.List`1[T] networkedVarList, System.IO.Stream stream, System.UInt64 clientId, MLAPI.NetworkedBehaviour logInstance) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.Messaging.InternalMessageHandler.HandleNetworkedVarDelta (System.UInt64 clientId, System.IO.Stream stream, System.Action`2[T1,T2] bufferCallback, MLAPI.Messaging.Buffering.PreBufferPreset bufferPreset) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkingManager.HandleIncomingData (System.UInt64 clientId, System.String channelName, System.ArraySegment`1[T] data, System.Single receiveTime, System.Boolean allowBuffer) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkingManager.HandleRawTransportPoll (MLAPI.Transports.NetEventType eventType, System.UInt64 clientId, System.String channelName, System.ArraySegment`1[T] payload, System.Single receiveTime) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkingManager.Update () (at <19597f6ed6a54f65b071432411566fd3>:0)

After more testing I’m pretty confident I’m either missing something fundamental with how Networked Dictionary’s are supposed to work or they simply don’t…

Another test that “should” 100% verify that I’m not adding a key twice. No Asserts thrown.

 if(IsServer)
            {

                Debug.Assert(!m_NetIntResource.ContainsKey("Test"), " HOW?????");
                if(!m_NetIntResource.ContainsKey("Test"))
                    m_NetIntResource.Add("Test", 10);

With the above code I still recieve the following error if an object is instantiated and spawned on server from client with a server RTP:

Network Manager Re-adding key

<19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkedBehaviour.HandleNetworkedVarDeltas (System.Collections.Generic.List1[T] networkedVarList, System.IO.Stream stream, System.UInt64 clientId, MLAPI.NetworkedBehaviour logInstance) (at <19597f6ed6a54f65b071432411566fd3>:0) MLAPI.Messaging.InternalMessageHandler.HandleNetworkedVarDelta (System.UInt64 clientId, System.IO.Stream stream, System.Action2[T1,T2] bufferCallback, MLAPI.Messaging.Buffering.PreBufferPreset bufferPreset) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkingManager.HandleIncomingData (System.UInt64 clientId, System.String channelName, System.ArraySegment1[T] data, System.Single receiveTime, System.Boolean allowBuffer) (at <19597f6ed6a54f65b071432411566fd3>:0) MLAPI.NetworkingManager.HandleRawTransportPoll (MLAPI.Transports.NetEventType eventType, System.UInt64 clientId, System.String channelName, System.ArraySegment1[T] payload, System.Single receiveTime) (at <19597f6ed6a54f65b071432411566fd3>:0)
MLAPI.NetworkingManager.Update () (at <19597f6ed6a54f65b071432411566fd3>:0)

Any ideas?

I’m afraid that this is very likely a bug in MLAPI. NetworkedList and NetworkedDictionary are experimental components and seem to have some deeper issues.
There is a similar bug with NetworkedList where it receives values twice when the server runs in host mode:
https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/issues/421

Thanks! I was afraid of that. May switch to a 3rd party solution that has more features production ready.