JFTR: I believe you are spot-on with the have_rows issue. Just yesterday, I stumbled over the error and narrowed it down to a single, lonely if ( have_rows('field') ) starting off the treatment of a flexible content field. And, like for the others here, the 5.1.2 update corrects it.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users