{"record":{"id":"c333031318b8c845","repo":"instructure/canvas-lms","slug":"error-retrieving-export-for-outcomes-service-response-body","errorCode":null,"errorMessage":"Error retrieving export for Outcomes Service: #{response.body}","messagePattern":"Error retrieving export for Outcomes Service: #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/models/outcomes_service/migration_service.rb","lineNumber":86,"sourceCode":"          else\n            false\n          end\n        else\n          raise \"Error retrieving export state for Outcomes Service: #{response.body}\"\n        end\n      end\n\n      def retrieve_export(export_data)\n        content_export_url = \"#{OutcomesService::Service.url(export_data[:course])}/api/content_exports/#{export_data[:export_id]}\"\n        response = CanvasHttp.get(\n          content_export_url,\n          headers_for(export_data[:course], \"content_migration.export\", id: export_data[:export_id])\n        )\n        if /^2/.match?(response.code.to_s)\n          json = JSON.parse(response.body)\n          json[\"data\"]\n        else\n          raise \"Error retrieving export for Outcomes Service: #{response.body}\"\n        end\n      end\n\n      def send_imported_content(course, content_migration, imported_content)\n        content_imports_url = \"#{OutcomesService::Service.url(course)}/api/content_imports\"\n        data = imported_content.merge(\n          context_type: \"course\",\n          context_id: course.id.to_s,\n          external_migration_id: content_migration.id\n        )\n        extractor = OutcomesService::MigrationExtractor.new(content_migration)\n        data = data.merge(\n          outcomes: extractor.learning_outcomes(course),\n          groups: extractor.learning_outcome_groups(course),\n          edges: extractor.learning_outcome_links\n        )\n        response = CanvasHttp.post(\n          content_imports_url,","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/outcomes_service/migration_service.rb#L68-L104","documentation":"Guard in OutcomesService::MigrationService#retrieve_export: the HTTP GET to the Outcomes Service content_exports API returned a non-2xx response, so this error is raised embedding the response body — the export could not be retrieved from the remote service.","triggerScenarios":"Fetching /api/content_exports/:id after export completion returns 4xx/5xx — bad or expired auth headers, wrong export id, or service error.","commonSituations":"Long-running exports whose JWT expires before retrieval; misconfigured service URL; remote service instability.","solutions":["Inspect the embedded response body for the HTTP status cause","Refresh/verify JWT in headers_for for scope 'content_migration.export'","Confirm export_id/course match what begin_export returned","Retry retrieval once the service is healthy"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  data = MigrationService.retrieve_export(export_data)\nrescue RuntimeError => e\n  raise unless e.message.start_with?('Error retrieving export')\n  attempts += 1\n  retry if attempts < 3\n  Canvas::Errors.capture(e)\nend","preventionTips":["Retrieve promptly after completion to avoid token expiry","Verify export_id immediately from begin_export return value","Alert on repeated retrieval failures per service endpoint"],"tags":["ruby","http","outcomes-service","export"],"backgroundTag":"http-error-response","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"}