← All errors
medium config

Cannot read properties of undefined (AutoEnhance dashboard)

Description

The AutoEnhance section of the dashboard throws a JS error 'Cannot read properties of undefined (reading enabled)' and fails to load.

Cause

The autoEnhance key is missing from settings.json entirely. The backend returned an empty dict {}, and the JS tried to read settings.autoUseGems.enabled from it.

Fix

The backend GET /api/dashboard/autoenhance-settings must return a full default schema merged over stored values — never raw settings.get('autoEnhance', {}). Add _AUTOENHANCE_DEFAULTS and merge before returning.

Code change

Before
return jsonify(settings.get('autoEnhance', {}))
After
return jsonify(_merge_autoenhance_defaults(settings.get('autoEnhance', {})))