Skip to content

fix: normalize invalid json escapes and compact on pull to prevent canvas blank-screen#7

Merged
sabbah13 merged 1 commit into
mainfrom
fix/json-attr-invalid-escapes-and-newlines
May 25, 2026
Merged

fix: normalize invalid json escapes and compact on pull to prevent canvas blank-screen#7
sabbah13 merged 1 commit into
mainfrom
fix/json-attr-invalid-escapes-and-newlines

Conversation

@bob-newo
Copy link
Copy Markdown
Collaborator

No description provided.

@bob-newo bob-newo requested a review from sabbah13 as a code owner May 25, 2026 14:03
Copy link
Copy Markdown
Owner

@sabbah13 sabbah13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Reviewed the algorithm and ran full pipeline tests — both bugs (3.7.2-a structural newlines, 3.7.2-b invalid _ escapes) reproduce on pre-PR code and disappear after the fix. Quote-aware walker handles edge cases correctly. Change-detection path stays sound via jsonValuesEqual canonicalization.

@sabbah13 sabbah13 merged commit d6c635a into main May 25, 2026
@sabbah13 sabbah13 deleted the fix/json-attr-invalid-escapes-and-newlines branch May 25, 2026 21:18
sabbah13 added a commit that referenced this pull request May 25, 2026
…storage (v3.7.3) (#8)

Workflow Builder canvas blank-screen, take two. Two bug families were
leaking through v3.7.1's STRING-coercion fix:

  (a) yaml.dump of a pretty-printed JSON string emitted a double-quoted
      scalar with \n escape sequences. patchYamlToPyyaml then rewrote
      those as a single-quoted scalar where \n became two literal chars,
      so Builder's JSON.parse choked on backslash-n as structural
      whitespace.

  (b) Canvas Markdown body uses \_ for emphasis. \_ is not a valid JSON
      escape per RFC 8259 and Chrome V8 JSON.parse throws on it,
      silently blanking the Builder.

normalizeJsonValueForStorage now (1) strips invalid escape sequences
via a quote-aware walker (fixInvalidJsonEscapes) and (2) compacts the
string via JSON.parse + JSON.stringify so the value is single-line and
survives yaml.dump -> patchYamlToPyyaml without escape corruption.
jsonValuesEqual continues to canonicalize both sides so the new compact
form does not spuriously push against pretty remotes.

Existing pretty-printed canvases in attributes.yaml will be reformatted
to compact form on next pull — one-time stylistic diff, no semantic
loss. 25 regression tests in test/json-attribute-roundtrip.test.js
cover both bug families and the full pull -> dump -> patch -> reload ->
JSON.parse pipeline.

Reported by Bob in #7. Closes the canvas blank-screen regression that
v3.7.1 only partially fixed.

Release surfaces touched:
  - package.json + package-lock.json (3.7.2 -> 3.7.3)
  - CHANGELOG.md (new [3.7.3] section + link refs)
  - README.md (top feature bullet)
  - CLAUDE.md (Implementation Status bullet + json-attr-utils.ts
    module entry under Sync Modules)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sabbah13
Copy link
Copy Markdown
Owner

Shipped as v3.7.3 — thanks Bob! 🎉

npm install -g newo@3.7.3
# or
npm install -g newo@latest

Smoke check on an affected customer:

newo pull   # existing pretty-printed canvases will re-emit compact (one-time stylistic diff)
newo push   # canvas now survives the round-trip; Builder no longer blanks

Release notes: CHANGELOG.md#373---2026-05-25
Tag: v3.7.3

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.

2 participants