Define and Validate Final config Schema for Custom Dashboards
The config field on Analytics::CustomDashboard currently accepts any JSON object, and validation is limited to ensuring the root value is a Hash. The final structure of the dashboard configuration is still evolving, so the existing JSON schema (custom_dashboard_config.json) is only a placeholder.
We need to define the final schema for config and update the JSON schema validation accordingly.
Problem
- The API currently accepts any arbitrary JSON shape.
- The JSON schema validator enforces structure, but the actual schema is not yet defined.
- As the dashboard feature evolves (e.g., layout, widgets, metadata), the schema must be formalized to prevent invalid configurations from being stored.
- We rely on a custom Ruby validator to ensure
configis a JSON object, which should eventually be enforced by the JSON schema alone.
Proposal
- Define the full expected structure of the
configobject, including:- Top-level keys (e.g.,
layout,widgets,metadata) - Type definitions for all fields
- Allowed values
- Required vs optional fields
- Top-level keys (e.g.,
- Update
custom_dashboard_config.jsonto reflect the finalized schema. - Remove or simplify the custom Ruby validator once the JSON schema enforces the correct structure.
- Add model specs to confirm invalid configurations are properly rejected.
Edited by 🤖 GitLab Bot 🤖