{"record":{"id":"8d4f641bbc6b26bc","repo":"instructure/canvas-lms","slug":"guid-is-invalid-guid","errorCode":null,"errorMessage":"GUID is invalid: #{guid}","messagePattern":"GUID is invalid: #(.+?)","errorType":"validation","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/controllers/outcomes_academic_benchmark_import_api_controller.rb","lineNumber":92,"sourceCode":"  def has_api_config\n    err = AcademicBenchmark.check_config\n    if err.nil?\n      true\n    else\n      render json: { error: \"The AcademicBenchmark API is not configured #{err}\" }\n      false\n    end\n  end\n\n  ##\n  # valid guids can only contain hex digits (letters all upper case),\n  # and must be separated between a '-' [8-4-4-4-12]\n  #\n  #   example:  A833C528-901A-11DF-A622-0C319DFF4B22\n  ##\n  def valid_guid(guid)\n    unless /[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}/i.match?(guid)\n      raise \"GUID is invalid: #{guid}\"\n    end\n  end\n\n  def parse_int(value)\n    Integer value\n  rescue\n    raise \"invalid value, must be integer: #{value}\"\n  end\n\n  def valid_options(hash)\n    options = {}\n    if hash.key? :calculation_method\n      options[:calculation_method] = parse_calculation_method hash[:calculation_method]\n      options[:calculation_int] = parse_calculation_int options[:calculation_method], hash[:calculation_int]\n    end\n    options[:mastery_points] = parse_int hash[:mastery_points] if hash.key? :mastery_points\n    options[:points_possible] = parse_int hash[:points_possible] if hash.key? :points_possible\n    unless hash[:ratings].nil?","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/controllers/outcomes_academic_benchmark_import_api_controller.rb#L74-L110","documentation":"OutcomesAcademicBenchmarkImportApiController#valid_guid validates Academic Benchmark GUID parameters against the 8-4-4-4-12 hex pattern and raises when the supplied guid is malformed. GUIDs must be UUID-like strings identifying the outcome document to import.","triggerScenarios":"Calling the academic benchmark import API with a guid that is not a hex UUID (e.g. 'abc', a numeric id, empty string, or truncated UUID).","commonSituations":"Client passes the Academic Benchmark outcome description/id instead of the GUID; GUIDs copied with lowercase is fine (regex is /i) but with extra whitespace or URL-encoding artifacts fail; swapped params put an integer where the guid belongs.","solutions":["Send the full 36-character hex UUID, e.g. A833C528-901A-11DF-A622-0C319DFF4B22.","Strip whitespace and URL-decode the guid before sending.","Verify you are using the Academic Benchmark GUID field, not an internal numeric id.","Validate client-side with a UUID regex before calling the endpoint."],"exampleFix":"// before\nparams[:guid] = \"12345\"\n// after\nparams[:guid] = \"A833C528-901A-11DF-A622-0C319DFF4B22\"","handlingStrategy":"validation","validationCode":"def valid_ab_guid?(guid)\n  /[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}/i.match?(guid.to_s.strip)\nend","typeGuard":null,"tryCatchPattern":"begin\n  import_outcomes(guid: guid)\nrescue RuntimeError => e\n  raise InvalidGuidParameter, guid if e.message.start_with?('GUID is invalid:')\n  raise\nend","preventionTips":["Copy GUIDs directly from Academic Benchmark and verify 36 hex chars in 8-4-4-4-12 groups.","Trim whitespace and URL-decode before sending.","Don't substitute numeric outcome ids for GUIDs.","Regex-validate client-side before the API call."],"tags":["api","guid","validation"],"backgroundTag":"invalid-identifier-format","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"}