Skip to content

Validate color values in styling files and stored styles - #2445

Draft
kmcginnes wants to merge 10 commits into
mainfrom
validate-styling-file-colors
Draft

kmcginnes wants to merge 10 commits into
mainfrom
validate-styling-file-colors

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Color fields in styling files and stored styles accepted any string. A value the app can't parse took down the graph and schema views until browser storage was cleared, and a blank edge label color broke the import preview.

User-facing: A styling file with a color that isn't hex, rgb(), hsl(), hwb(), or a color name now fails to load, and a dialog lists each type, field, and value to fix. Stored styles with an unusable color fall back to the default instead of breaking the app.

  • One gate: isAllowedColorValue (utils/), built on the color library the app already uses. Callers trim spaces before or after a color first, since the renderers can't read a padded value.
  • On import: stylingParser rejects non-color values in all five color fields (vertex color, borderColor; edge lineColor, labelColor, labelBorderColor). A padded color is trimmed and stored trimmed. Blank colors still import, for older files.
  • At load: the read-time transforms trim padded colors and drop unusable ones so the default applies. Older versions stored imported colors as written, so a padded color saved before this change is trimmed rather than dropped. Vertex styles already had a transform; edge styles get a new transformEdgeStyles. This also covers backup restores.
  • Import preview: buildStyleImportPlan now runs incoming entries through the same transforms, so the preview and the write see the same cleaned styles. useApplyStyleImport no longer transforms on its own.
  • Docs: the styling-file, read-time-transform, and retired-shapes ADRs are updated, and the settings guide names the accepted color formats.
styling file ──▶ stylingParser (trim, reject non-colors)
                   └▶ buildStyleImportPlan (transformVertexStyles / transformEdgeStyles)
                        └▶ preview ──▶ useApplyStyleImport ──▶ storage
storage ──▶ transformVertexStyles / transformEdgeStyles (trim, drop unusable colors) ──▶ atoms

Validation

Before: A styling file with "labelColor": "nope" imported, and the graph and schema views threw on every load. A file with "labelColor": "" threw as soon as the import preview opened.

After: The file is rejected with a dialog listing each bad value:

Load Failed dialog listing each invalid color by type and field

Verified live: Settings → Styles → Load, in Firefox, against the dev server on this branch. Unparseable and non-color values were rejected per field. In Chrome, a padded " #fff " loaded as #fff, and padded colors saved by an older version were trimmed on reload. A file with blank edge label colors opened the preview and applied without errors. Valid hex, rgb(), and hsl() colors loaded as before.

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I have verified pnpm checks passes with no errors.
  • I have verified pnpm test passes with no failures.
  • I have covered new added functionality with unit tests if necessary.
  • I have updated documentation if necessary.

@kmcginnes
kmcginnes force-pushed the validate-styling-file-colors branch from 2872ada to aa070a3 Compare November 25, 2026 00:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid color in an imported styling file permanently breaks the graph and schema views Blank edge style colors are not dropped at the read boundary

1 participant