Skip to content

fix(serialization): escape only what JSON requires in changelog.json and the run record - #332

Merged
goldbarth merged 1 commit into
mainfrom
relaxed-json-escaping
Oct 6, 2026
Merged

goldbarth merged 1 commit into
mainfrom
relaxed-json-escaping

Conversation

@goldbarth

@goldbarth goldbarth commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Closes #226

  • Decision: relax both files. changelog.json and the run record are read, committed and diffed by people. The default encoder wrote every backtick as \u0060, so each code span in a rendering and in a description was hard to read raw, and every non-ASCII title was unreadable. Both files now use JavaScriptEncoder.UnsafeRelaxedJsonEscaping and escape only what JSON requires.
  • Why the "Against" point in the issue does not hold: a consumer that parses the file, such as the planned widget, reads byte-identical strings with either encoder, so the default escaping never protected it. It only helps someone who pastes the raw file into an HTML <script> element. The strings come from pull request titles and the text a model wrote from them, so a consumer escapes them on output in any case; changelog-json.md now says so.
  • Why not UnicodeRanges.All: measured against the same string, it frees non-ASCII only. Backticks, quotes, ' and + stay escaped, and the backticks are the bulk of the escapes in a real run (12 in changelog.json, 297 in the run record, per the comment on changelog.json escapes '+', quotes and every non-ASCII character #226).
  • Both files the same: relaxing the run record alone would have left the published file the hard one to read, and the two files looking different.
  • Shape: one ReadableJson.Options() for both, and a static Readable instance on each source-generated context, used for reading and writing. The [JsonSourceGenerationOptions(WriteIndented = true)] attribute is gone, since the options carry the indentation. Still source-generated and reflection-free.
  • No schemaVersion bump: the meaning of the file does not change, and every parser reads the same values as before. No fixture changed: none held an escaped character.
  • Docs: the "Known issue: escaped characters" section in changelog-json.md is now "Characters". The JSON examples in the README, changelog-json.md and run-record.md show what the files now contain. The run record's link to that section and the jq note in testing.md are updated.

Verified:

  • Encoder comparison on one string with +, quotes, backticks, <b>&amp;, ü, ’, “”, • and an emoji: the default escapes all of them; UnicodeRanges.All only frees the non-ASCII ones; the relaxed encoder writes all of them as themselves except the emoji (a surrogate pair). All three round-trip to the same string.
  • The new test fails against the old encoder and passes with the change.

Tests: FactBaseRoundTripTests gains one test that holds a title with ü, a backtick, ', +, " and <b>, a rendering and a toolVersion with + to their literal form in both files, and reads the title back. All tests pass.

@goldbarth goldbarth self-assigned this Oct 6, 2026
@goldbarth
goldbarth merged commit 87b3c12 into main Oct 6, 2026
4 checks passed
@goldbarth
goldbarth deleted the relaxed-json-escaping branch October 6, 2026 13:22
goldbarth added a commit that referenced this pull request Oct 7, 2026
Follows #344. Step 1 of `docs/development/releasing.md`.

- **Why now:** the launch points are merged, and the binary people
install is still `0.1.0-preview.3`, which has none of them. The
announcement needs a release that holds what the README and the docs on
`main` describe.
- **What ships since preview.3,** 63 commits:
- a first run: `chartula doctor` (#295, grouped in #341), `chartula
--version` (#286), a free `preview` (#292), progress while a run works
(#297, with a spinner and `--plain` in #340), a first tag from the first
commit with a confirmation for a large range (#282);
- what a release contains: commits without a pull request (#291), issue
numbers at every depth (#293), a sentence for a release with nothing for
developers (#307 in #333);
- checks and prompts: pull request text quoted and bounded (#338), no
false flag for a wrapped phrase or a fenced block (#336), flags set
apart from the entries (#331);
- publishing: the token checked before the first model call (#285), a
published release not replaced unless asked (#335);
- the files: `changelog.json` without descriptions and readable as text
(#294, #332).
- **Breaks to state in the notes,** as `docs/versioning.md` asks of a
preview:
- `changelog.json` is schema version 2: a change's `description` is gone
(#294). The run record is schema version 3 and holds the complete facts.
- `generate` stops on a tag whose release is already published;
`--replace-published` restores the old behaviour (#335).
- An option a command does not take stops the run (#301), and
`--whole-history` is gone (#282).
- The terminal output changed form (#340 to #342): the summary's first
line, audience headings in place of `--- Technical ---`, and `doctor`'s
last line. A script that reads those lines needs a look; exit codes and
the files are unchanged.
- The csproj `Version` is the single source; nothing else carries the
number.

**After merge:** tag the merge commit on `main` with `v0.1.0-preview.4`
and push it; `release.yml` builds the draft, `chartula generate --tag
v0.1.0-preview.4` writes the notes into it, and publishing runs
`install.yml`. The pinned `v0.1.0-preview.3` in `docs/ci.md` and
`docs/install.md`, and the template link in the `doctor` samples, move
to the new tag once the release exists, with the changelog pull request
of step 6.

**Verified:** the built CLI prints `chartula 0.1.0-preview.4+<commit>`.

Tests: no test changed. Full suite 1,010 passing, build without
warnings.
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.

changelog.json escapes '+', quotes and every non-ASCII character

1 participant