Unlike minecraft:damage, minecraft:repair_cost cannot be properly removed.
Whereas, with damage, the value is not set to a default, but rather to `null`. Meaning the item cannot be damaged.
But for repair_cost, the value is also not set to the default and also `null`, however, upon using an anvil (with this item on the left side, to retain its components) the repair cost is set to 1. Which is the same behavior as if the previous repair cost was the default '0'
Reproduce:
Create this item modifier in a datapack:
{
"function": "set_components",
"components": {
"!minecraft:repair_cost": {}
}
}
Give yourself a sword and remove the repair cost from the sword.
/item modify entity @s weapon.mainhand test:no_repair_cost
You can verify that the repair cost is nullified (/data get):
[CHAT] Player has the following entity data: {components: {"minecraft:damage": 2, "!minecraft:repair_cost": {}}, id: "minecraft:netherite_sword"}
3. damage the sword a bit and repair with another sword in an anvil.
4. Check the repair cost: it is now set to 1.
I would expect that repair cost behaves the same as damage, where removing the component vs setting the default, does not result in the same behavior.
Related issues
Attachments
Comments

Please attach the datapack used to reproduce this issue

Thank you for your report!
After consideration, the issue is being closed as Invalid.
You have posted a feature request or a suggestion. This site is for bug reports only.
For suggestions, please visit The official Minecraft feedback site or visit the Minecraft Feedback Discord server.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki