Skip to content

v4.9.0 migration errors when course/components have no _tutor (_autoScrollWhenInline) #134

Description

@taylortom

Bug

The Tutor - 4.8.0 to 4.9.0 migration in migrations/v4.js throws when a course or component has no existing _tutor object:

TypeError: Cannot read properties of undefined (reading '_autoScrollWhenInline')

Cause

The mutate steps use _.set(course._tutor, '_autoScrollWhenInline', true) and _.set(component._tutor, '_autoScrollWhenInline', true). When _tutor is undefined, _.set is given an undefined target and silently no-ops, so the property is never written. The following checkContent steps then read course._tutor._autoScrollWhenInline / _tutor._autoScrollWhenInline off the still-undefined _tutor and throw.

The block's own testSuccessWhere fixtures hit this — { _type: 'course' } (no _tutor) and { _id: 'c-105', _component: 'mcq' } (no _tutor).

Unlike the earlier blocks in the same file (e.g. 4.0.0, 4.0.0 to 4.1.0), this block does not ensure _tutor exists before populating it.

Fix

Set via the parent with a dotted path so lodash creates the intermediate _tutor when missing (and preserves an existing one):

_.set(course, '_tutor._autoScrollWhenInline', true);
_.set(component, '_tutor._autoScrollWhenInline', true);

How this surfaced

Caught during an Adapt Authoring Tool course import, where the failed migration step now correctly aborts the import.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions