How to render HTML output in hook_ENTITY_TYPE_presave()
In hooks which are not executed in a render context use renderPlain(), see Cron error: LogicException : Render context is empty

$html = \Drupal::service('renderer')-&gt;renderPlain($processedResult);


Caveat: Text filters can bubble up metadata which you ignore by storing only the HTML. For a custom text filter this might be OK when you know it doesn't depend on cache metadata and attachments, but don't use this as a general approach. This can have security implications, like revealing data to non-authorized users.