Trados 2019 validation error, cannot generate target, Keyref fails to refer to some key

I just finished translating a large docx file with 33k Japanese characters. However, I cannot generate a target file because of errors. The error message says:

SDLXLIFF validation error at line 1358 offset 611082: The key sequence 'XXX (omitted here)' in 'YYY (omitted here)' Keyref fails to refer to some key.

I have three errors with the same text except the XXX and YYY parts.
I clicked the error in the error report but it does not jump to the segment with error.
My file has up to line 1078 and there is no line 1358 (not sure if this is supposed to refer to a Trados file line number).

I then copied the content of the Word file over to a new Word file and generated a new Trados project with the same TM. I had to connect lots of segments (original Word file has lots of line-breaks within a sentence). The QA check did not report an error. However, when I tried to generate a target file, it was aborted due to the same three errors I originally got. The QA check now has three errors.

I use Trados 2019 SR2.


emoji