Add schema validation for SettingGroupManager.registerGroups() to catch configuration errors early
Categories
(Firefox :: Settings UI, task)
Tracking
()
People
(Reporter: jaws, Assigned: jaws)
Details
Attachments
(1 file)
Engineers report that the SettingGroupManager.registerGroups() schema is error-prone when adding new settings manually. Common mistakes include:
- Wrong types for properties (e.g.,
inProgress: "true"instead ofinProgress: true) - Missing required fields (e.g., omitting
idin items) - Invalid
headingLevelvalues (must be 1-6) - Invalid nesting structure for
itemsandoptions
These errors result in a blank/failed rendering of about:preferences, which is difficult to debug because the error only manifests at render time with non-descriptive failures.
Solution
This patch adds multi-layered validation:
- Runtime validation in
SettingGroupManager.registerGroup()that catches errors at registration time (before rendering) with descriptive error messages that include the exact path to the invalid property. - ESLint rule (
mozilla/valid-setting-group-config) for static analysis that catches errors at lint time before code runs. - Browser tests covering all validation scenarios.
Example error message (before this patch)
SettingNotDefinedError: No Setting with id "undefined"
Example error message (after this patch)
Invalid SettingGroupConfig:
Group "myGroup": "headingLevel" must be an integer from 1-6
Group "myGroup": "inProgress" must be a boolean
Group "myGroup".items[0]: "id" is required and must be a string
Testing
- Browser tests:
./mach test browser/components/preferences/tests/browser_setting_group_validation.js --headless - ESLint rule tests:
cd tools/lint/eslint/eslint-plugin-mozilla && npm test -- --grep "valid-setting-group-config"
| Assignee | ||
Comment 1•19 minutes ago
|
||
This includes runtime checks in SettingGroupManager and a new ESLint rule for static analysis.
Description
•