Harden API error safety