Backend: Do not crash on invalid URI content

When requesting to decode invalid URI content, it would crash
since we didn't catch the exception. Send an API error in this case.
Also includes tests for said scenario.