We have tested this on 7.2 and it looks like the binary attachment gets deleted but attachment property is not removed from data. So in case of your content it will be like this after deletion:
I’m pretty sure it’s the same behaviour on 6.15.x as well.
So you can either run an additional update (with contentLib.modify) which will remove the data property, or wait for the bugfix. Here’s the bug we registered.
Oh, I am not sure. Maybe it is because the content used to be Enonic CMS content, and now is used in Enonic XP after we converted it with your https://github.com/enonic/cms2xp ?
We tested it a bit more and currently behaviour is as follows:
If you upload an attachment from Content Studio then it will create a binary attachment AND a data property. When you remove the attachment from CS, it will remove both the binary and the data property.
If you upload an attachment via contentLib.addAttachment, it will only create a binary attachment. In this case attachment won’t be visible in Content Studio. Again, if you remove it via contentLib.removeAttachment it will only remove the binary. Visually nothing will change in CS because attachment wasn’t visible in the first place.
So, if you uploaded an attachment as described in 1 (or it was already there after migration), but remove it as described in 2, then data property will remain and the attachment will look as present in CS even though binary is removed by contentLib.
This is inconsistent and we’ll discuss how to improve this. Meanwhile, you can run a script (contentLib.modify) right after executing removeAttachment which will remove data property with the same name.
To summarize my initial problem: the content in question used to be Enonic CMS content, and was converted to Enonic XP content. This conversion did not handle the images properly, but by reprocessing the content with toolbox (with https://xp.readthedocs.io/en/stable/reference/toolbox/reprocess.html#reprocess) the contentLib.removeAttachment works as if the content was uploaded via contentLib.addAttachment(your case number 2). So, I’ll run contentLib.modify after removing the attachment to remove the data property as well.
Not sure if this is directly inconsistent, N but it is exposing node api rather than content API. Content api should support upload of attatchments via the specific atrachment input