Skip to content

Bug: Migration issue with _accessibility._isEnabled #833

@swashbuck

Description

@swashbuck

Subject of the issue

stringToBoolean migration helper overwrites existing boolean true values with false during v2.2.0 migration

Your environment

  • Framework v2.2.0 migration (src/core/migrations/v2.js)

Steps to reproduce

  1. Have a course where one or more boolean config fields (e.g. config._accessibility._isEnabled) are already stored as a proper boolean true (not the string "true")
  2. Run the v2.2.0 migration

Expected behaviour

Fields that are already correct booleans should be preserved as-is.

Actual behaviour

The stringToBoolean helper (line 310 of v2.js) only returns true when the input is the string "true". When it receives a non-string value — including an already-correct boolean true — it falls through to return the defaultValue. For _isEnabled, the default is false, so any course with _isEnabled: true has it silently overwritten to false after migration.

Suggested fix

Add a boolean passthrough at the top of stringToBoolean:

function stringToBoolean(str, defaultValue) {
  if (_.isBoolean(str)) return str;
  if (!_.isString(str)) return defaultValue;
  return str.toLowerCase() === 'true';
}

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions