Very simple short and straightforward. I found that if I give myself firework_rockets with a custom tag called 'test', the item has an nbt={Tags:['test']}. The command I use is /give @s firework_rocket{Tags:['test']} 64
However once the firework is shot via a crossbow, I tried to retrieve its data and to my surprise, found out that the Tags:['test'] is not stored directly in the entity, but more discretely in an nbt called tag=. For example: entity firework_rocket has the following data ---
{OnGround:0b,Air:300s,blah blah blah, tag: {Tags:["test"]},Count:64b}
As seen from above, this Tags:["test"] tag in being stored in an nbt tag called tag.
If I want to detect a specific nbt tag such as the Air tag, I could do so simply with execute at @e[nbt={Air:300s}] run summon tnt
But what I want to do here is to detect the Tags:["test"] tag. /execute at @e[nbt={tag:{Tags:["test"]}}] simply wont work.
I don't know if you want a command to run when you select the firework or when it turns into an entity, but here are both commands. For both instances:
Entity :
/execute as @e[nbt={tag:{Tags:["test"]}}] at @s run <command>Item :
/execute as @e[nbt={SelectedItem:{tag:{Tags:["test"]}}}] at @s run <command>