We consider a stochastic capacitated lot sizing problem with in-line rework. Both defective and defect-free products can be the result of an imperfect production process in real-world production systems. However, the proportion of defective items in a production lot is subject to uncertainty. For economic and environmental reasons, the possibility to rework defective products appears reasonable since these products usually have considerable value. In this paper, a nonlinear model formulation for integrated lot sizing and rework planning is proposed. We use a sample average approach to approximate the generic nonlinear model formulation. To cope with the randomness of the proportion of defective products, we apply a flexible planning approach that allows the adjustment of production and rework quantities. We conduct extensive numerical investigations to evaluate the performance of the proposed planning approach.