Thank you for the proposed patch! Unfortunately, it does not seem to fix the issue (even though the log is definitely different now). If you hit a roadblock and suspect the hardware, please do not hesitate to let me know as these are cheap boards and I'm happy to source another one.
STM32L031K6 (NUCLEO-L031K6): flash mass erase fails