{"record":{"id":"07f571ad1565ba28","repo":"instructure/canvas-lms","slug":"a11y-scan-skipped-resource-resource-id-due-to-size-limit","errorCode":null,"errorMessage":"[A11Y Scan] Skipped resource #{@resource&.id} due to size limit.","messagePattern":"\\[A11Y Scan\\] Skipped resource #(.+?) due to size limit\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/services/accessibility/resource_scanner_service.rb","lineNumber":206,"sourceCode":"  def handle_size_limit_failure(scan)\n    error_message = case @resource\n                    when Attachment\n                      I18n.t(\n                        \"This file is too large to check. PDF attachments must not be greater than %{size} MB.\",\n                        { size: MAX_PDF_SIZE / 1.megabyte }\n                      )\n                    else\n                      I18n.t(\n                        \"This content is too large to check. HTML body must not be greater than %{size} KB.\",\n                        { size: MAX_HTML_SIZE / 1.kilobyte }\n                      )\n                    end\n    scan.update(\n      workflow_state: \"failed\",\n      error_message:\n    )\n    log_to_datadog(scan)\n    Rails.logger.warn(\"[A11Y Scan] Skipped resource #{@resource&.id} due to size limit.\")\n  end\n\n  def resource_workflow_state\n    # Check if resource implements the new interface\n    if @resource.respond_to?(:scannable_workflow_state)\n      @resource.scannable_workflow_state\n    else\n      case @resource\n      when WikiPage, DiscussionTopic, Announcement\n        @resource.active? ? \"published\" : \"unpublished\"\n      when Assignment\n        @resource.published? ? \"published\" : \"unpublished\"\n      when Attachment\n        @resource.processed? ? \"published\" : \"unpublished\"\n      else\n        resource_name = @resource.respond_to?(:resource_class_name) ? @resource.resource_class_name : @resource.class.name\n        raise ArgumentError, \"Unsupported resource type: #{resource_name}\"\n      end","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/accessibility/resource_scanner_service.rb#L188-L224","documentation":"Accessibility::ResourceScannerService#handle_size_limit_failure marks an AccessibilityScan as failed with an error_message and logs this warning when the resource's content exceeds the scanner's size limit. The resource is skipped (scan failed) rather than scanned, to protect the scanner from oversized payloads.","triggerScenarios":"scan_resource encounters a resource (assignment/page/attachment content) whose rendered content or body exceeds the configured maximum scan size, triggering handle_size_limit_failure which fails the scan and logs the skip.","commonSituations":"Users upload extremely large HTML pages, assignments with huge embedded content, or attachments over the scanner size cap; environments with low size-limit configuration scanning large courses.","solutions":["Increase the scanner's size limit configuration if the resources are legitimately scannable","Reduce the resource content size (trim embedded media/base64 blobs) and re-run the scan","Chunk or preprocess oversized content before scanning so it fits under the cap","Treat the failed scan as expected — surface the workflow_state 'failed' + error_message to users so they know the resource was skipped"],"exampleFix":"// before\nscan.update(workflow_state: \"failed\", error_message:)\nlog_to_datadog(scan)\nRails.logger.warn(\"[A11Y Scan] Skipped resource #{@resource&.id} due to size limit.\")\n\n// after: check size before scheduling the scan\ndef scan_resource\n  return log_size_skip if content.to_s.bytesize > MAX_SCAN_BYTES\n  # ... normal scan path\nend","handlingStrategy":"validation","validationCode":"if content.to_s.bytesize > MAX_SCAN_BYTES\n  Rails.logger.warn(\"resource #{resource.id} exceeds scan size limit\")\nelse\n  ResourceScannerService.new(resource).scan_resource\nend","typeGuard":"def scannable?(resource)\n  resource.present? && resource_content(resource).to_s.bytesize <= MAX_SCAN_BYTES\nend","tryCatchPattern":null,"preventionTips":["Pre-check content size before enqueueing scans","Keep the size limit configurable per environment","Strip or downsize embedded media/base64 payloads before scanning","Monitor failed scans with error_message to find chronically oversized resources"],"tags":["ruby","accessibility","size-limit","scanner"],"backgroundTag":"file-size-limit-exceeded","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"}