When encode form was submitted in async mode, validation errors returned HTML (render_template) instead of JSON, causing "Unexpected token '<'" parse errors in the browser. Added _error_response() helper that returns JSON in async mode and HTML flash in sync mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>