{"record":{"id":"9a698f26eb3f674c","repo":"instructure/canvas-lms","slug":"a-section-did-not-pass-validation-section-section-id-name","errorCode":null,"errorMessage":"A section did not pass validation (section: #{section_id} / #{name}, course: #{course_id}, error: #{section.errors.full_messages.join(\", \")})","messagePattern":"A section did not pass validation \\(section: #(.+?) / #(.+?), course: #(.+?), error: #(.+?)\\)","errorType":"validation","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/sis/section_importer.rb","lineNumber":156,"sourceCode":"\n        if section.changed?\n          if section.workflow_state_changed? &&\n             section.workflow_state_was == \"deleted\" &&\n             section.default_section? &&\n             CourseSection.active.where(course_id: section.course_id, default_section: true).exists?\n            # trying to restore a previously default section but there's one already so undefault the restored one\n            section.default_section = false\n          end\n          section.sis_batch_id = @batch.id\n          if section.valid?\n            section.save\n            data = SisBatchRollBackData.build_data(sis_batch: @batch, context: section)\n            @roll_back_data << data if data\n          else\n            msg = \"A section did not pass validation \"\n            msg += \"(\" + \"section: #{section_id} / #{name}, course: #{course_id}, error: \"\n            msg += section.errors.full_messages.join(\", \") + \")\"\n            raise ImportError, msg\n          end\n        else\n          @sections_to_update_sis_batch_ids << section.id\n        end\n\n        @success_count += 1\n      end\n    end\n  end\nend\n","sourceCodeStart":138,"sourceCodeEnd":167,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/sis/section_importer.rb#L138-L167","documentation":"Save-failure path in SIS::SectionImporter::Work#add_section: the CourseSection failed model validation (section.valid? false or save failed), so ImportError is raised with the section's full error messages, identifying section/name/course and the validation errors.","triggerScenarios":"Thrown at lib/sis/section_importer.rb:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the embedded validation messages and fix the row values (e.g. duplicate sis id, bad dates)","Re-run the SIS batch after correction"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}