Open Bug 2010485 Opened 10 hours ago Updated 19 minutes ago

Add schema validation for SettingGroupManager.registerGroups() to catch configuration errors early

Categories

(Firefox :: Settings UI, task)

task

Tracking

()

ASSIGNED

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 of inProgress: true)
  • Missing required fields (e.g., omitting id in items)
  • Invalid headingLevel values (must be 1-6)
  • Invalid nesting structure for items and options

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:

  1. 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.
  2. ESLint rule (mozilla/valid-setting-group-config) for static analysis that catches errors at lint time before code runs.
  3. 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"

This includes runtime checks in SettingGroupManager and a new ESLint rule for static analysis.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: