Improper error handling when returning 500 [RTFACT-18438]

external_document