instructure/canvas-lms · error · Translation::TranslationError
e.message
Error message
e.message
What it means
The fallback branch of handle_cedar_errors in lib/translation.rb:145: any Cedar exception not matching the known classes is re-raised as a generic TranslationError carrying the original e.message. It means the translation backend failed in an unexpected way not covered by the specific error mappings.
Solutions
- Inspect the raised TranslationError message (it preserves e.message) to identify the true upstream cause
- Check Cedar service status/credentials/network connectivity
- Rescue TranslationError and implement a graceful fallback (return original text, retry later)
- Update handle_cedar_errors with an explicit mapping if a new recurring upstream error class appears
Example fix
// before
result = Translation::Service.translate_text(text, from:, to:)
// after
begin
result = Translation::Service.translate_text(text, from:, to:)
rescue TranslationError => e
logger.warn("translation failed: #{e.message}")
result = text
end Defensive patterns
Strategy: try-catch
Try / catch
begin
translate_text(text, from:, to:)
rescue TranslationError => e
logger.error("translation failed: #{e.message}")
text # graceful fallback to untranslated content
end Prevention
- Always rescue TranslationError at service boundaries
- Monitor e.message trends to catch new upstream error classes
- Add circuit-breaker/retry for transient upstream failures
When it happens
Trigger: translate_text or translate_html encountering an upstream exception class outside {SameLanguageTranslationError, ContentTooLongError, UnsupportedLanguageError, ValidationError} — e.g. network/auth failures from the Cedar client, rate limiting, or new error types after a gem upgrade.
Common situations: Cedar service outage or timeout; expired/invalid credentials surfacing as an unmapped client exception; a new error class introduced upstream before this mapping was updated.
Related errors
- UnsupportedLanguageError
- ValidationError
- A new_id, '# ', referenced an existing # and the # with #…
- A new_integration_id, '#
- A student referenced a non-existent user #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/d45e49fbc74fd628.
Report an issue: GitHub.
Appendix: source
Thrown at lib/translation.rb:145
def collect_translation_stats(src_lang:, tgt_lang:, type:)
tags = %W[type:#{type} source_language:#{src_lang} dest_language:#{tgt_lang}]
InstStatsd::Statsd.distributed_increment("translation.invocations", tags:)
end
def handle_cedar_errors
yield
rescue => e
case e.class.name
when /SameLanguageTranslationError/
raise SameLanguageTranslationError
when /ContentTooLongError/
raise TextTooLongError
when /UnsupportedLanguageError/
raise UnsupportedLanguageError
when /ValidationError/
raise ValidationError
else
raise TranslationError, e.message
end
end
end
end
View on GitHub (pinned to 1c9f0bb801)