Hi, I have a similar problem as I first had a P0102 code. I actually replaced my MAF sensor with a used one from the junkyard. It came of a 3.8 Camaro and the part numbers matched. After installing it, it threw another code P0171 which to my understanding is also MAF related. Should I just buy a brand new one? I'm really trying to save myself a $150 investment. I recently replaced all the vacuum hoses and checked for leaks.
Before replacing the MAF the car ran fine but would stall only in cold and high moisture conditions. I did the unplug test, with no difference. That told me that I needed to replace the MAF. Now the car is idling rough, but not stalling anymore. Thus, giving me P0171.
*Note: 1999 Pontiac Grand Prix GTP (VIN "1")