Skip to content

BUG-001: JSON.stringify-keyed option diff can cause data loss / stale config #66

Description

@ApexYash11

Summary

The wrapper diffs prop changes by stringifying option objects and comparing the strings (src/ImageEditor.tsx, remountKey / updatableKey). This is fragile and can cause bad behavior.

Severity: P1 (correctness / data loss)

Problem

  • Key-order sensitivity — semantically identical options objects that differ only in property declaration order produce different strings → a spurious remount (the README explicitly warns remount-tier options destroy unsaved edits, so this is silent data loss) or a spurious updateOptions call.
  • Drops undefined / functionsJSON.stringify silently omits them, so real changes inside options can be invisible to the diff → stale editor configuration without any warning.
  • Throws on circular references — a circular reference inside options crashes during render.

Verification

  • Code-proven from src/ImageEditor.tsx (lines around remountKey / updatableKey). Reproduced logically; no runtime repro shipped.

Suggested fix

Use structural deep-equality or a canonical form (stable, sorted-key serialization); compare values, not raw strings. Keep the repo's 100% coverage threshold by adding tests for the key-order and dropped-field cases.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions