A board that passes every electrical test on the bench can still fail in the field. Condensation, airborne salt, fuel vapour and sustained vibration attack assemblies in ways a functional test never sees, and by the time the symptom appears the unit is usually already deployed.
Conformal coating is the lighter of the two answers. A thin polymer film follows the contours of the board, sealing solder joints and fine-pitch leads against moisture and contamination while adding almost nothing to weight or thickness. Acrylics are the easiest to apply and to remove for rework; silicones tolerate wider temperature swings; urethanes resist solvents but are unforgiving once cured.
Potting goes further. Encapsulating the assembly in a resin removes the effects of vibration and shock almost entirely and makes the unit effectively sealed, at the cost of weight, thermal behaviour and any prospect of repair. It is the right decision for a sealed sensor destined for a vehicle chassis, and the wrong one for an assembly you expect to service.
The decision belongs at design review, not after the first field return. Masking requirements, connector keep-outs and cure schedules all change how the board should be laid out, and retrofitting protection onto a design that did not plan for it is where most of the cost hides.