{"record":{"id":"ca2c631741a17f58","repo":"instructure/canvas-lms","slug":"an-unexpected-error-occurred-while-submitting-feedback","errorCode":null,"errorMessage":"An unexpected error occurred while submitting feedback.","messagePattern":"An unexpected error occurred while submitting feedback\\.","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/base_ai_feedback.rb","lineNumber":49,"sourceCode":"  def resolve(input:)\n    root_account_uuid = check_feature_and_permissions!(input)\n\n    result = CedarClient.submit_feedback(\n      response_id: input[:response_id],\n      feedback_type: input[:feedback_type],\n      feature_slug:,\n      root_account_uuid:,\n      current_user:,\n      comment: input[:comment]\n    )\n\n    { response_id: result.response_id }\n  rescue GraphQL::ExecutionError => e\n    Rails.logger.error(\"[#{self.class.name} GraphQL ExecutionError] #{e.message}\")\n    raise e\n  rescue => e\n    Rails.logger.error(\"[#{self.class.name} ERROR] #{e.message}\")\n    raise GraphQL::ExecutionError, I18n.t(\"An unexpected error occurred while submitting feedback.\")\n  end\n\n  private\n\n  # Subclasses must perform feature flag and permission checks here,\n  # then return the root_account_uuid string.\n  def check_feature_and_permissions!(_input)\n    raise NotImplementedError, \"#{self.class} must implement check_feature_and_permissions!\"\n  end\n\n  # Subclasses must return the Cedar feature slug string.\n  def feature_slug\n    raise NotImplementedError, \"#{self.class} must implement feature_slug\"\n  end\nend\n","sourceCodeStart":31,"sourceCodeEnd":65,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/base_ai_feedback.rb#L31-L65","documentation":"BaseAiFeedback subclasses (AI feedback submissions mutations) wrap resolve in a catch-all rescue. Any exception other than GraphQL::ExecutionError raised while submitting AI feedback is logged as '[ClassName ERROR]' and re-raised as a generic 'An unexpected error occurred while submitting feedback.' ExecutionError. It masks the true cause from API clients by design.","triggerScenarios":"Any mutation inheriting app/graphql/mutations/base_ai_feedback.rb (e.g. createAiFeedback) whose resolve raises: backend AI call failure, missing root_account_uuid, nil result, or validation errors not wrapped as ExecutionError.","commonSituations":"AI feedback feature flag enabled but backend endpoint misconfigured; response object nil because the AI service returned empty; subclass failing its own permission/flag checks with a plain RuntimeError.","solutions":["Grep server logs for '[<MutationClassName> ERROR]' to find the real exception","Verify the AI feedback feature flag and backend service are correctly configured on the root account","Retry after confirming the response/result object is non-nil before use","Rescue known failure modes explicitly in the subclass and raise a descriptive GraphQL::ExecutionError"],"exampleFix":"// before\nrescue => e\n  Rails.logger.error(\"[#{self.class.name} ERROR] #{e.message}\")\n  raise GraphQL::ExecutionError, I18n.t(\"An unexpected error occurred while submitting feedback.\")\n// after\nrescue AiFeedback::BackendError => e\n  raise GraphQL::ExecutionError, I18n.t(\"AI feedback service unavailable: %{msg}\", msg: e.message)","handlingStrategy":"try-catch","validationCode":"// verify feature availability before submitting feedback\nconst flags = await canvas.get('/api/v1/accounts/self/features')\nif (!flags.includes('ai_feedback')) throw new Error('AI feedback not enabled')","typeGuard":"function hasResponseId(r) { return r != null && typeof r.response_id === 'string' && r.response_id.length > 0 }","tryCatchPattern":"try {\n  const res = await client.mutate({ mutation: SUBMIT_AI_FEEDBACK, variables })\n  return res.data\n} catch (e) {\n  if (e.graphQLErrors?.some(g => g.message.includes('unexpected error occurred while submitting feedback'))) {\n    // correlate with '[ClassName ERROR]' server log entry\n  }\n  throw e\n}","preventionTips":["Confirm the AI feedback feature flag and backend URL are configured on the root account","Check subclasses' permission checks pass before calling","Never send feedback payloads to disabled environments","Rescue specific backend errors in subclasses instead of relying on the generic rescue"],"tags":["graphql","mutation","ai-feedback","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}