Replication error: Sub-object not in parent actor, but replicates fine

Hi, I am trying to use UObject as the data class for my Inventory system in an online game, which means the UObject has to support replication.

I followed this post to implement the replication

The data all replicates fine via ReplicateSubobject but I am getting an error message, and I have no idea what does it actually means.
Based on the error message, it sounds like all the sub objects have to be in the parent actor but that means all data have to be in the parent actor which doesn’t sound quite right…

Here is how it works :

Player’s Inventory(ActorComponent) has a list of Slot (UObject)
when Player picks up the WeaponItemActor (Actor), the WeaponItemActor will be added into Player’s Inventory’s unoccupied Slot.

WeaponItemActor has a WeaponItemData (UObject) that contains information such as number of bullets in the gun, compatible ammo type, which AmmoItem(UObject) it is currently using etc.

The moment I pick it up, the following error occurs

LogNetTraffic: Error: UActorChannel::ReadContentBlockHeader: Sub-object not in parent actor. SubObj: WeaponItemData /Game/FirstPersonCPP/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.BP_WeaponActor2.WeaponItemData_0, Actor: FirstPersonCharacter_C /Game/FirstPersonCPP/Maps/UEDPIE_1_FirstPersonExampleMap.FirstPersonExampleMap:Persis
tentLevel.FirstPersonCharacter_C_1

However, all data seems to be replicating just fine. So I am not really sure what this error message means or indicates. I have searched around and found a couple of posts stating the same thing but I do not quite understand them. Would appreciate if anyone can shine some light on why this error message is popping up and what does it mean.

Note: The WeaponItemActor lives in the scene and creates WeaponItemData in its BeginPlay()

Solved.

After a dive in the engine source, turns out it is because I added WeaponItemActor’s WeaponItemData into Slot. The sub-object (WeaponItemData) doesn’t want to be separated from its parent Actor (WeaponItemActor), which makes sense after looking at the engine source, since the sub-objects relies on their parent to replicate them. Would be helpful if the error message can be more descriptive though.

So the solution is :
instead of adding only WeaponItemData into Inventory’s Slot, I have to add WeaponItemActor into Slot. If I really just need the WeaponItemData, then what I need to do this use DuplicateObject() to duplicate WeaponItemActor’s WeaponItemData with Outer being set to Inventory’s Slot and then store the duplicated WeaponItemData into Inventory’s Slot. This way the WeaponItemData rely on Inventory’s Slot (technically, is the Player actor) to replicate its properties.