@tryashtar can you give an example? I find that the the non-JSON string is simply rejected by the command parser and so never executed. And, say, to remove horse armor I've tried things like setting the specific armor slot to "air" or to Count:0, which don't work.
I agree that this works for CustomName, and I'd guess for other string properties.
However, my bug was marked a dup of this one, and I was looking at non-string properties, such as SaddleItem. And it does not work (afaict) for a horse's SaddleItem. I tried
/data modify entity f4d501d5-adc6-4bff-8d79-07924348f0a5 SaddleItem set value "" /data modify entity f4d501d5-adc6-4bff-8d79-07924348f0a5 SaddleItem set value {id:""} /data modify entity f4d501d5-adc6-4bff-8d79-07924348f0a5 SaddleItem set value {id:"",Count:0b} /data modify entity f4d501d5-adc6-4bff-8d79-07924348f0a5 SaddleItem set value {id:"",Count:0}
Other things that don't work: {} {id:"\"\""}
So it's a workaround for some cases, but not all I'm afraid.
Requesting ownership of this ticket since the current reporter has been inactive since May of 2019. I'm willing to keep this report updated and will continue to provide all of the necessary information. 🙂
Just stumbled upon this bug myself. Made me very confused as to why my functions weren't working properly for a couple days before I realized this command simply just wasn't working. But I've found for the time being, an easy fix is instead of running /data remove entity @s CustomName, use /data modify entity @s CustomName set value ''
@unknown: Stop reposting information that adds nothing new to the report. Everything you have to say has already been said (MC-267259 included), and every comment sends unnecessary email notifications to watchers. Yes, MC-267259 is a thing, and is working as intended, and yes, this issue (MC-128225) is a more important problem now, as already stated by @unknown in this comment. That's why the Mojang Priority for this ticket has been bumped from "Low" to "Important".
A similar fix can also be applied to other places, specifically command blocks, containers, beacons, banners and enchanting tables.
An alternative way would be to make a method dedicated to retrieving a custom name, with the same code as above, that returns the custom name.
The fix comes from removing the custom name if the tag is not present. Through testing, this seems to work as expected, /data remove does remove the custom name, other types of changes also don't cause any issues.
Still exist in 1.20.5-rc1. It seems like we won't be able to remove custom names for 2 versions in a row after having been able to in another way since 1.13. Ouch.
Does reloading the world (leave and enter) fix it?