The reason was the post_id
key simply missing from the upload query.
It was there for the normal posts, but was being omitted in the custom-post-type uploads.
No idea why. The issue had something to do with the javascript uploader settings.
So I’ve asked another question regarding the pluploader
here and have managed to find the solution myself.
I do not know why was the post_id
being excluded, but at least it works now.