{"record":{"id":"1d81346d3421dc8d","repo":"instructure/canvas-lms","slug":"child-content-tag-was-not-found-for-self-class-name-id","errorCode":null,"errorMessage":"Child content tag was not found for #{self.class.name} #{id} - either this is from old code or something bad happened","messagePattern":"Child content tag was not found for #(.+?) #(.+?) - either this is from old code or something bad happened","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/models/master_courses/restrictor.rb","lineNumber":175,"sourceCode":"      changed_columns.delete(state_column)\n      changed_columns << \"manually_deleted\"\n    end\n    if changed_columns.any?\n      tag_content = if is_a?(Assignment) && (submittable = submittable_object)\n                      submittable # mark on the owner's tag\n                    else\n                      self\n                    end\n      MasterCourses::ChildContentTag.transaction do\n        child_tag = MasterCourses::ChildContentTag.where(content: tag_content).lock.first\n        if child_tag\n          new_changes = changed_columns - child_tag.downstream_changes\n          if new_changes.any?\n            child_tag.downstream_changes += new_changes\n            child_tag.save!\n          end\n        else\n          Rails.logger.warn(\"Child content tag was not found for #{self.class.name} #{id} - either this is from old code or something bad happened\")\n        end\n      end\n    end\n  end\n\n  def create_child_content_tag\n    # i thought about making this a bulk insert at the end of the migration but the race conditions seemed scary\n    if @importing_migration && is_child_content?\n      @importing_migration.master_course_subscription.content_tag_for(self)\n    end\n  end\n\n  def check_before_overwriting_child_content_on_import\n    return unless @importing_migration && is_child_content?\n\n    child_tag = @importing_migration.master_course_subscription.content_tag_for(self) # find or create it\n    return unless child_tag && child_tag.downstream_changes.present?\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/master_courses/restrictor.rb#L157-L193","documentation":"MasterCourses::Restrictor#mark_downstream_changes records which columns changed on a locked master-course item by updating its child content tag. When no MasterCourses::ChildContentTag exists for the object, it logs this warning and skips tracking — either the item predates master-course locking code or a tag that should exist is missing.","triggerScenarios":"An edit to a master-course (blueprint) locked object whose child content tag lookup returns nil — objects created before the blueprint feature existed, tags deleted, or unsaved/non-master-template content passing through the restrictor.","commonSituations":"Old courses retrofitted as blueprint courses (items have no child tags); direct console/data fixes that removed tags; edits to content not actually governed by a master template; race conditions during template migration.","solutions":["Usually safe to ignore for legacy content: the change simply isn't tracked as a downstream change","If sync tracking matters, re-run the master course association/tag migration to backfill missing child tags","Verify the item belongs to a master template (check MasterCourses::MasterTemplate associations)","Check for code deleting child tags and restore referential integrity","master_courses_child_content_tags table"],"exampleFix":"// before\n# silent warn on missing tag\nRails.logger.warn(\"Child content tag was not found ...\")\n// after\nRails.logger.warn(\"Child content tag was not found ...\")\nCanvas::Errors.capture(e_missing_tag, content_type: self.class.name, content_id: id) if template_content?","handlingStrategy":"fallback","validationCode":"tag = MasterCourses::ChildContentTag.where(\n  content_type: obj.class.name, content_id: obj.id\n).first\nputs('tag missing — change will not be synced') unless tag","typeGuard":"def blueprint_managed?(obj)\n  MasterCourses::ChildContentTag.exists?(content: obj)\nend","tryCatchPattern":"begin\n  mark_downstream_changes(columns)\nrescue => e\n  Rails.logger.warn(\"downstream tracking failed: #{e.message}\")\nend","preventionTips":["Re-run blueprint tag backfill migrations for retrofitted master courses","Only expect downstream tracking for items governed by a master template","Monitor for code paths that delete child_content_tags","Treat the warning as benign for legacy/old-code content"],"tags":["master-courses","blueprint-courses","content-tags","logging"],"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"}