The entity UUID provided is in an invalid format
That error is for the target selector, which usually occurs when no target was found (and is unrelated to the remainder of the command). Ensure there are targets available first or that there are no typos in your selector.
Using direct NBT detection will not reliably allow you to count the number of items. If you look specifically for a
Count of 10, you'll only find wheat in an exact stack of 10 in a single slot, rather than 10 wheat spread across the inventory in any number of slots.
To accomplish that, you'll need to use CommandStats, which sets a score related to the success of a command. The
AffectedItems trigger will set a score based on the number of items found.
Objective to hold the value.
/scoreboard objectives add ItemCount dummy
AffectedItems trigger to apply to the player. This may need to run on a clock if new players can join at any time. The players will set their own "ItemCount" score based on the success of a command relevant to
AffectedItems (such as
/stats entity @a set AffectedItems @a[c=1] ItemCount
In order for CommandStats to modify a target's score, that target must be tracked in the objective prior. This may also need to run on a clock.
/scoreboard players add @a ItemCount 0
The following must be run in numerical order on a clock.
Cause all players to clear 0 wheat in their inventory. While this does not remove any wheat, the command will return an
AffectedItems value equal to the number of items that could have been cleared.
/execute @a ~ ~ ~ clear @a[c=1] minecraft:wheat -1 0
Players will then have their "ItemCount" score set equal to the number of wheat all across their inventory, regardless if they're not in the same stack. You can then target players based on their score, which also allows for a range of values (which is otherwise not possible with direct NBT detection).
/say @a[score_ItemCount_min=10] has 10 wheat.