If you setup a trade with a villager that includes items that were renamed and custom edited(modified some of its stats such as damage using command blocks) using command blocks then if you try trading with the villager once the trade is up, the villager will not trade with you and you will get the item you were trading back at your inventory like no trade took place.If you edit the villager and exit the editing menu and try trading again,the villager will now be able to trade with you.Don't know why this happens and you could contact the author somehow to maybe try fixing it.
Thank you.