{"record":{"id":"716736c2557cfc02","repo":"instructure/canvas-lms","slug":"an-old-integration-id-data-change-old-integration-id","errorCode":null,"errorMessage":"An old_integration_id, '#{data_change.old_integration_id}', referenced a non-existent #{type} and was not changed.","messagePattern":"An old_integration_id, '#(.+?)', referenced a non-existent #(.+?) and was not changed\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/change_sis_id_importer.rb","lineNumber":152,"sourceCode":"      def find_item_to_update(column, details, type, data_change)\n        if data_change.old_id.present?\n          old_item = details[:scope].find_by(column => data_change.old_id)\n        end\n        if data_change.old_integration_id.present?\n          old_int_item = details[:scope].find_by(integration_id: data_change.old_integration_id)\n        end\n        if data_change.old_id.present? && data_change.old_integration_id.present?\n          raise ImportError, \"An old_id, '#{data_change.old_id}', referenced a different #{type} than the old_integration_id, '#{data_change.old_integration_id}'\" unless old_item == old_int_item\n\n          return old_item\n        end\n        if data_change.old_id.present? && data_change.old_integration_id.blank?\n          raise ImportError, \"An old_id, '#{data_change.old_id}', referenced a non-existent #{type} and was not changed.\" unless old_item\n\n          return old_item\n        end\n        if data_change.old_id.blank? && data_change.old_integration_id.present?\n          raise ImportError, \"An old_integration_id, '#{data_change.old_integration_id}', referenced a non-existent #{type} and was not changed.\" unless old_int_item\n\n          old_int_item\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":134,"sourceCodeEnd":160,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/change_sis_id_importer.rb#L134-L160","documentation":"find_item_to_update raises this when old_id is blank, old_integration_id is present, and no record matches scope.find_by(integration_id => old_integration_id). The record identified only by its integration_id does not exist in the root-account scope, so no re-keying is possible.","triggerScenarios":"change_sis_id row relying solely on old_integration_id where no row of the type has that integration_id — record deleted, integration_id already changed/cleared, or wrong account.","commonSituations":"External SIS sends its own ids assuming Canvas stored them as integration_id, stale exports after integration_id reassignment, or type mismatch (integration_id looked up in the wrong scope for the declared type).","solutions":["Verify the integration_id exists: scope.where(integration_id: old_integration_id).exists?.","Fall back to identifying the record via old_id instead.","Refresh the export so the integration_id matches Canvas's current data."],"exampleFix":"// before: integration_id not in Canvas\nuser,,new-id,INT-404\n// after: use the id Canvas actually has\nuser,U-100,new-id","handlingStrategy":"validation","validationCode":"if dc.old_id.blank? && dc.old_integration_id.present?\n  unless scope_for(dc.type).where(integration_id: dc.old_integration_id).exists?\n    raise ArgumentError, \"unknown integration_id #{dc.old_integration_id}\"\n  end\nend\nprocess_change_sis_id(dc)","typeGuard":null,"tryCatchPattern":"begin\n  process_change_sis_id(dc)\nrescue SIS::ImportError => e\n  if e.message.include?('old_integration_id')\n    logger.warn(\"unknown integration_id=#{dc.old_integration_id}: skipped\")\n  end\nend","preventionTips":["Confirm Canvas actually stores the external system's id as integration_id for that type.","Prefer old_id lookups; integration_id lookups are fragile to reassignment.","Validate integration_ids against the current DB before generating change rows."],"tags":["sis","ruby","import","not-found"],"backgroundTag":"record-not-found","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"}