Run this to get a bundle containing dirt:
/give @s minecraft:bundle[minecraft:bundle_contents=[{id:"minecraft:dirt"}]]
Hold the bundle in your main hand, and enter this to check if the bundle contains a diamond:
/execute if items entity @s weapon.mainhand *[minecraft:bundle_contents~{items:{contains:[{item:"minecraft:diamond"}]}}]
Clearly, the bundle did not contain a diamond, and yet this outputs "Test passed, count: 1".
I tested this on minecraft:bundle_contents
and minecraft:container
. The only case I could find where this bug doesn't apply is when the collection being matched is empty.
Ah, apparently it's supposed to be
items
, notitem
, even though https://www.minecraft.net/en-us/article/minecraft-java-edition-1-20-5 says the opposite.