Both Buyer and Seller, California
It can be very expensive to obtain permits after the fact. Portions of the construction will likely need to be removed to allow for visual inspections. Assuming the inspections pass (don't assume that - it is very likely some or most of the work will need to be redone) you will be left with the cost of the permits (considerable) and repair labor/materials. Other homeowners fly under the radar and play cat and mouse, never making any repairs or filing permits but in the end it usually catches up with them through a sale, neighbor complaint, prospective buyer files a report, etc.