The contents slot for the /item command doesn't operate with shot arrows, tridents, and fireballs. This functionality is available for objects like item frames but isn't applicable to arrows, tridents, and fireballs (including both large fireballs from ghasts and small fireballs from blazes). Despite these entities having an item field, it serves different purposes. For arrows and tridents, it determines the item the player receives when picking them up, while for fireballs, it determines the item they should render as.
Steps to reproduce
Shoot an arrow
/item replace entity @e[type=minecraft:arrow,limit=1,sort=nearest] contents with minecraft:acacia_boat
Observed: The arrow's item field was not substituted with an acacia boat, and an error message was encountered.
Expected: The arrow's item field should be replaced with an acacia boat as anticipated.
This affects entities minecraft:arrow, minecraft:spectral_arrow, minecraft:trident, minecraft:fireball, minecraft:spectral_arrow, minecraft:small_fireball and possibly more.
Confirmed! Also affects 24w14a.