Expected behavior:
The command,
/execute if items entity @s weapon enchanted_book[stored_enchantments={levels:{"minecraft:swift_sneak":3}}]
will succeed if the held item has Swift Sneak III and only that enchantment—once it has other enchantments, the component no longer matches exactly, and the command will fail.
In order to check for any book with the enchantment present, I'd expect to use
/execute if items entity @s weapon enchanted_book[stored_enchantments~{levels:{"minecraft:swift_sneak":3}}]
or a similar command.
Actual Behavior:
When the last command is used, a syntax error is reported, "Malformed 'minecraft:stored_enchantments' predicate: 'Not a list [...]'". If formatted to be a list, eg.
{{/execute if items entity @s weapon enchanted_book[stored_enchantments~[{levels:{"minecraft:swift_sneak":3}}]]
/execute if items entity @s weapon enchanted_book[stored_enchantments~[{"minecraft:swift_sneak":3}]]
/execute if items entity @s weapon enchanted_book[stored_enchantments~[{id:"minecraft:swift_sneak",lvl:3}]]
the command always succeeds as long as the stored_enchantments component is present. Upon further testing, it appears to always succeed no matter the contents of the list (even if there are none), identical to the following check:
/execute if items entity @s weapon enchanted_book[stored_enchantments]
This error also occurs with the regular enchantments
component, though in this case the command always fails.
The syntax is