This is a common scam. $50 for a nasty letter from an attorney and they have the victim rushing to make them happy. If you have any liability at all, your wife shares 50% because the house is community property. You should inform your divorce attorney as well as your wife's attorney because everyone stands to lose.
Regarding the flex pipe they want; it's not what they want it is what the code requires. They don't just get to bonus an upgrade. The pipe installed will have a life expectancy and depending on when it was installed, the value will be pro-rated for depreciation.
You, as the seller, are most likely not liable because you had to disclose everything. It was the responsibility of your contractor to know about and pull the appropriate permits for the job. You would only have the liability if you had performed the work yourself, then it is expected that you should know about the permit requirements. Also if you knew a permit was required and you and your contractor proceeded without it. The new owner might have a case against the contractor, depending on when the work was done.
Your realtor has to do "due diligence". He or she should have gone over everything with you regarding disclosure according to the law. It is the realtor's responsibility to ask the seller about everything. Therefore your realtor has a certain liability in this issue. The work performed by your contractor, involving the gas pipe, should have been disclosed.
The realtor(s) should have gone over all of the disclosures, you would have signed, and your wife also, that everything is accurate as you understand it. Then the buyer(s) would also sign off on everything. If you didn't agree to any contingencies, like you will fix any issues at any expense for a period of time, the buyer owns that leaking gas pipe.
You need to go back and read through your final sales contact and verify that the disclosures were made AND if there are any contingencies in the contract.
Good luck,
Joe