When you edit/modify/produce an NBT reload of a villager or wandering trader, its inventory gets doubled. For example 1 bread turns into 2, 2 stacks of 20 seeds turn into 2 stacks of 40 seeds, 50 <item> turn into 100 <item> (a new stack is generated for storing the extra 36).
Reproduction steps:
1. Spawn a villager and give him any items you want (remember they can pick up food)
2. Check his inventory with
/data get entity @e[type=minecraft:villager,limit=1,sort=nearest] Inventory
3. Update his NBT with any command, for example
/data merge entity @e[type=minecraft:villager,limit=1,sort=nearest] {Health:15.0f}
/data modify entity @e[type=minecraft:villager,limit=1,sort=nearest] Health set value 5.0f
4. Check his inventory again. All items are doubled.
If you try to modify the Count of one of his items, the result will be NewCount = InputCount + OldCount (instead of just NewCount = InputCount).
If you try to modify the ID of one of his items, the result will be 1 stack of old item + 1 stack of input item (instead of just 1 stack of input item).
Related issues
Attachments
Comments


Thank you for your report!
We're tracking this issue in MC-112826, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
-- I am a bot. This action was performed automatically! Please report any issues in Discord or Reddit

@tryashtar oh I didn't see the bug was already reported, but it's not fixed hahah.
I know about what Searge said about commands that edit nbt, but it's been 3~4 years, there is a whole new command system now, a datapack community that rely on vanilla commands working properly.
Surely the response Searge said back in the days is a bit obsolete now.