I had the same problem.I tried adding "monitor flash mass_erase" to the debug configuration, as suggested above, without solving the error.But,I opened a new project on CubeIDE, just an empty project.I loaded it onto the MCU and it removed the error....