instructure/canvas-lms · error · CedarAi::Errors::GraderError
friendly_cedar_error_for(e)
Error message
friendly_cedar_error_for(e)
What it means
GradeService#call wraps Cedar (AI grading) API calls. CedarClient validation-style errors (ValidationError, CedarLimitReachedError, UnsupportedLanguageError, ContentTooLongError) have static user-safe messages, so they are re-raised as CedarAi::Errors::GraderError with a message produced by friendly_cedar_error_for(e). The bracketed message is just the raise expression; the actual message depends on the Cedar error.
Solutions
- Read the raised GraderError message to identify which Cedar condition fired (limit vs validation vs language vs length).
- Shorten the submission/rubric content (trim via normalize_rubric_for_prompt, truncate essay text) before sending to Cedar.
- Wait or request a limit increase if CedarLimitReachedError; back off and retry the grading job later.
- Ensure the submission language is supported or skip Cedar grading for unsupported languages.
Example fix
// before service.call(...) # content too long -> GraderError // after prompt = GradeService.normalize_rubric_for_prompt(rubric_data) service.call(...) if prompt.to_s.length <= MAX_CEDAR_CONTENT_LENGTH
Defensive patterns
Strategy: try-catch
Try / catch
begin
GradeService.call(...)
rescue CedarAi::Errors::GraderError => e
render json: { error: e.message }, status: :unprocessable_entity
end Prevention
- Pre-truncate submission/rubric content to Cedar's content limits
- Normalize rubric data with GradeService.normalize_rubric_for_prompt before sending
- Monitor Cedar usage limits and back off when near them
- Check language support before submitting for AI grading
When it happens
Trigger: Cedar API rejects the grading request: prompt/rubric content too long, request exceeds a Cedar usage limit, unsupported language detected, or input fails Cedar client-side validation during grading submission.
Common situations: Very large submissions or rubrics hitting Cedar content limits; account-level Cedar rate/usage limits exhausted; grading essays in a language Cedar doesn't support; malformed rubric data normalized incorrectly before send.
Related errors
- An unexpected error occurred while grading.
- A new_id, '# ', referenced an existing # and the # with #…
- A new_integration_id, '#
- A student referenced a non-existent user #
- A user did not pass validation
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/ed17a967f66ac949.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/grade_service.rb:58
begin
grading_results = CedarClient.grade_essay(
description: @assignment,
essay: @essay,
rubric: cedar_rubric,
feature_slug: "grading-assistance",
root_account_uuid: @root_account_uuid,
current_user: @current_user
)
map_grade_essay_results_to_canvas(grading_results, @rubric)
# These subclasses have static, user-safe messages and can be shown directly.
# If new CedarClientError subclasses are added with user-safe messages, add them here.
rescue InstructureMiscPlugin::Extensions::CedarClient::ValidationError,
InstructureMiscPlugin::Extensions::CedarClient::CedarLimitReachedError,
InstructureMiscPlugin::Extensions::CedarClient::UnsupportedLanguageError,
InstructureMiscPlugin::Extensions::CedarClient::ContentTooLongError => e
raise CedarAi::Errors::GraderError, friendly_cedar_error_for(e)
rescue InstructureMiscPlugin::Extensions::CedarClient::CedarClientError => e
Rails.logger.error("[GradeService] Cedar API error: #{e.message}")
raise CedarAi::Errors::GraderError, friendly_cedar_error_for(e)
rescue => e
Rails.logger.error("[GradeService] Unexpected error: #{e.class}: #{e.message}")
raise CedarAi::Errors::GraderError, I18n.t("An unexpected error occurred while grading.")
end
end
def self.normalize_rubric_for_prompt(rubric_data)
rubric_data.each_with_object({}) do |criterion, acc|
key = criterion[:description]
acc[key] = {
"Criteria" => (criterion[:ratings] || []).map do |rating|
{
"Description" => rating_description_for(criterion, rating),
"Points" => rating[:points]
}View on GitHub (pinned to 1c9f0bb801)