P0171 for lean bank 1 sensor 1
“bank 1” is meaningless for this engine, it’s used to differentiate which side of a V6 or V8, but you have a straight 4.
“sensor 1” usually means the before-the-cat O2 sensor. There’s an O2 sensor both upstream of the cat, and downstream. This code is for the upstream one.
“lean” means there’s too much air (or O2) getting into the engine coming from somewhere or another, and it is having a difficult time dealing with all that extra air.
That particular O2 sensor’s job is to assist the engine computer in setting the correct air to fuel mixture to make the engine run the smoothest and least emissions possible. It uses that sensor’s reading in conjunction with information from other sensors, especially the MAF sensor, the coolant temp sensor, and the ambient temp sensor. What it is saying is that it is having to inject more gas than it thinks it should, given the readings from all the sensors other than the O2 sensor.
There’s three common problems to look for first
unmetered air is getting into the engine’s intake manifold. All the air that gets into the engine is supposed to go through the MAF sensor, where it is measured as it passes by. If extra air leaks in somehow or another, this confuses the engine computer. Vacuum leaks, torn intake boots, compromised gaskets, or even just the intake manifold bolts are loose are all possibilities. Shops have simple ways to test for all of these.
air is getting into the exhaust stream upstream of that O2 sensor. You’d think if you had an exhaust leak, it would only go one way, from the exhaust system out to the air. But the way the pistons move both directions, outside air can also be drawn into the exhaust system if there’s a leak. The engine computer assumes everything that crosses the path of the O2 sensor came from the combustion chambers, so it gets confuses if any outside air get into that stream. Cracked exhaust manifolds on Toyota 4-bangers are not an unheard of problem here, and could cause this symptom. Or a bad exhaust manifold gasket, among others.
The O2 sensor isn’t working correctly. Those are pretty robust, and from comments here, failures are very uncommon, esp O2 sensors less than 10 years/150K miles old. I’d suspect a broken or intermittent wire between the sensor and the engine computer before I’d suspect the sensor.
If you remain concerned about the cat, ask the shop to do a cat back-pressure test. If the cat was clogged I suppose this symptom could result. But if it was just not doing a good job of cleaning the exhaust of pollutants, that would usually trigger a code, but not this one.