Could be a weak extractor spring,
Or could be that the rig is short stroking,
Or the ejector is binding in the bolt face channel,
Or the face of the bolt is retracting all the way behind the back of the ejection port edge at end of stroke,
Or could just be that the chamber is still covered in assembly/storage grease with debris you did not chamber brush with CLP scrub out before the barrel was fired.
Bluntly, after you are sure that the rifle has been cleaned and lubed correctly, load only a single round in a mag, charge the mag while leaving the empty mag still in the well, and fired the single round. The bolt should be locking back on the catch (catch in front of the face of the bolt, and not just under the carrier), and if the problem is only a weak ejector spring, then the spent case rim should not be torn or bend at all. Also, the spent case should be throw 10' to 15' out the ejection port.