The bug
The 26.30.20 preview changelog stated:
Fixed loot table container filling so when no empty slots remain, generated loot now merges into matching non-full stacks instead of failing to place (MCPE-233039)
This issue was not fixed correctly. Items can still fail to generate. The wording of the fix makes clear the issue: when no empty slots remain, generated loot that doesn’t have any matching non-full stacks will still fail to place. This causes hearts of the sea to still sometimes fail to generate in buried treasure chests.
The correct fix is to spread stacks only after every item is successfully generated and added to the chest, not during.
How to reproduce
Download the same test world from MCPE-233039
Run
/structure load test:chest ~ ~ ~repeatedly and look inside
Expected result
A diamond sword should always be present
Observed result
Sometimes the diamond sword fails to generate
Hi!
Thank you for your report!
We're already tracking this issue at MCPE-233039 , so I will resolve and link this ticket as a Duplicate.
I suggest also to browse through the main issue for potential fixes.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki