Skip to content

fix: validate and sanitize JSON file imports#9

Merged
jonathan-beebe merged 1 commit into
mainfrom
fix/006-json-import-missing-structure-validation
Mar 29, 2026
Merged

fix: validate and sanitize JSON file imports#9
jonathan-beebe merged 1 commit into
mainfrom
fix/006-json-import-missing-structure-validation

Conversation

@jonathan-beebe
Copy link
Copy Markdown
Owner

Summary

  • Extract sanitizeImportedFramework() pure function in logic/framework.ts
  • Validates quadrant structure (label, color, items array) with safe defaults
  • Filters items without text, defaults missing x/y to 10, generates missing id/createdAt
  • Prevents malformed JSON files from being persisted to localStorage and crashing the app
  • Resolves BUG-006

Test plan

  • 10 new unit tests for sanitizeImportedFramework covering: null/invalid input, missing name, wrong quadrant count, valid input, missing labels, missing colors, missing items array, missing coordinates, items without text, missing item IDs, missing axes
  • Full test suite passes (223 tests)

🤖 Generated with Claude Code

Extract sanitizeImportedFramework() that validates quadrant structure,
defaults missing labels/colors/items, filters items without text, and
ensures x/y coordinates are numbers. Prevents malformed JSON files from
being persisted to localStorage and crashing the app.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 29, 2026

Deploy Preview for golden-scone-6bfeb1 ready!

Name Link
🔨 Latest commit 2a179a4
🔍 Latest deploy log https://app.netlify.com/projects/golden-scone-6bfeb1/deploys/69c94cbf167486000878989b
😎 Deploy Preview https://deploy-preview-9--golden-scone-6bfeb1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@jonathan-beebe jonathan-beebe merged commit 7c68ac8 into main Mar 29, 2026
5 checks passed
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.

1 participant