Note
The block states of certain blocks shouldn't be overwritten by identical state values due to an error message in the process. Thus, the report only refers to an issue in the container's state replacement accessible only whilst Cheats are enabled.
The bug
Container blocks, unlike any other block entity, can contain items. This is linked to nbt data, named also Items, that updates when items are added/removed (e.g. the Chest).
So, I put it to the test to see if some block entities had the same update effect after being set with the same block state, and I discovered that certain block entities (such as containers) replace their content only in their nbt (unless they are linked to these items) and could possibly cause issues.
One example can be replicated with the Campfire during its cooking state; replacing it with identical state values result in the appearance of an error message although the food items in its nbt have been updated, the food items are still visible (which pauses the cooking process)... Here are some experiments to prove my point on this issue:
Replacing any interactable container with the same state values removes its contents completely (despite the error message showing up). This applies to:
Chests
Hoppers
Droppers/Dispensers
Shulker boxes
Furnaces
Barrels
Blast furnaces
Smokers
Replacing a Lectern (wielding a book) with the same state values however, doesn't lose its content but results in the {}book GUI to instantly close when opened.
Replacing a Campfire with another (during its cooking process) comes back with the error message (if all its states match the previous), resulting in the cooking process to pause with its food items still displayed.
EDIT: Related issue in MC-31100
Reproduction steps
Place a campfire containing raw food items
Replace that block with the same state values using the command:
/setblock [campfire location] campfire[states of target block]
(now occurs the error message)
Execute the command:
/data get block [campfire location] Items
Does this still happen in the newest version? This has not been updated in 1 year.