Skip to content

Write the Litestream config as JSON and drop serde_yaml - #1251

Merged
epompeii merged 1 commit into
develfrom
u/ep/litestream-json
Oct 16, 2026
Merged

epompeii merged 1 commit into
develfrom
u/ep/litestream-json

Conversation

@epompeii

@epompeii epompeii commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Problem

Lint / Cargo Deny Advisories fails on devel (run https://github.com/bencherdev/bencher/actions/runs/38831217036) with, among others, RUSTSEC-2024-0449: unsafe-libyaml is unmaintained. It reaches the tree only through serde_yaml, which is itself deprecated (0.9.34+deprecated).

The only use of serde_yaml is one serde_yaml::to_string in JsonDisasterRecovery::into_yaml, which serializes the generated Litestream config. The API writes that string to /etc/litestream.yml (etc/litestream.yml in debug builds) and passes it to litestream restore and litestream replicate with -config <path> -no-expand-env.

Change

  • The Litestream config is serialized with serde_json::to_string_pretty and written to the same path. Litestream reads its config with gopkg.in/yaml.v2 (v2.4.0 in go.mod at both v0.5.16 and v0.5.17), which reads JSON documents, so the file name and both Litestream invocations stay as they are. The struct shapes, kebab-case renames, and skip_serializing_if attributes are unchanged, so the parsed config is identical with one exception. serde_json writes U+007F to U+009F, U+FFFE, and U+FFFF unescaped where serde_yaml escaped them, and yaml.v2, a YAML 1.1 parser, rejects all of them except U+0085, which it reads as a space. A config value containing one of those characters now makes Litestream refuse to start, or for U+0085 changes the parsed value. Paths, bucket names, endpoints, and S3 credentials are ASCII in practice.
  • Names that said YAML now say what they are: JsonDisasterRecovery::into_litestream_config, LitestreamError::Serialize (now carrying serde_json::Error), LitestreamError::WriteConfig, and the four into_litestream_config* tests, which now assert the emitted JSON.
  • serde_yaml is removed from the workspace, bencher_json (including the db feature), and bencher_api, which takes serde_json in its place. Cargo.lock drops serde_yaml and unsafe-libyaml.

Verification

  • cargo clippy --locked -p bencher_json -p bencher_api --all-features --all-targets -- -D warnings: clean.

  • cargo nextest run --locked -p bencher_json --all-features: 229 passed.

  • cargo deny --locked check advisories: RUSTSEC-2024-0449 is gone. The four rustls advisories (RUSTSEC-2026-0346 to -0349) were fixed by Repin rui314/setup-mold to the current v1 and update rustls #1248, which this branch is rebased on.

  • Parse equivalence: one fully populated config (S3 replica with path, endpoint, region, sync_interval; snapshot with interval and retention; validation; checkpoint with all three fields) rendered by devel as YAML and by this branch as JSON. Both load to the same document, litestream databases -config <file> -no-expand-env lists the same database and replica on 0.5.16 and 0.5.17, and litestream replicate logs the same parsed settings for both:

    msg="replicating to" type=s3 sync-interval=1s bucket=gate-bucket path=<prefix> region=us-east-1 endpoint=http://127.0.0.1:9000
    msg="starting validation monitor" system=store interval=6h0m0s
    msg="starting compaction monitor" system=store level=9 interval=1h0m0s
    
  • Edge values: a secret and an S3 path made of a double quote, a backslash, $HOME, : , leading and trailing spaces, and é parse identically from the devel YAML and this branch's JSON on both Litestream versions, authenticate against MinIO, and round trip; $HOME is not expanded. The exception above came from feeding U+007F, U+0080, U+0085, U+0090, U+009F, U+FFFE, and U+FFFF through Litestream's own config reader at both versions.

  • Boot round trip: a debug api build with plus, its plus.disaster_recovery replicating to a local MinIO container with the fully populated S3 settings above. On first boot the API writes the JSON config, litestream restore exits 0 (no matching backups found), and litestream replicate uploads LTX files to the bucket. A signup through POST /v0/auth/signup then replicates; after stopping the API and deleting the whole data directory, the next boot's litestream restore recreates the database from MinIO with the same user row (same UUID) and no migrations to run. The same round trip passes with the file replica scheme, and both pass on Litestream 0.5.16 (what devel ships) and 0.5.17.

CI on this pull request is the final check.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBencher
Branchu/ep/litestream-json
Testbedintel-v1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
Adapter::Json📈 view plot
🚷 view threshold
5.11 µs
(-2.32%)Baseline: 5.23 µs
5.46 µs
(93.52%)
Adapter::Magic (JSON)📈 view plot
🚷 view threshold
4.92 µs
(-2.30%)Baseline: 5.04 µs
5.23 µs
(94.17%)
Adapter::Magic (Rust)📈 view plot
🚷 view threshold
24.24 µs
(-8.31%)Baseline: 26.44 µs
32.37 µs
(74.89%)
Adapter::Rust📈 view plot
🚷 view threshold
4.46 µs
(-3.99%)Baseline: 4.65 µs
5.15 µs
(86.62%)
Adapter::RustBench📈 view plot
🚷 view threshold
4.46 µs
(-3.97%)Baseline: 4.65 µs
5.15 µs
(86.67%)
🐰 View full continuous benchmarking report in Bencher

serde_yaml is deprecated and pulls in the unmaintained unsafe-libyaml
(RUSTSEC-2024-0449). Its only use was serializing the generated Litestream
config, and Litestream parses its config with go-yaml, which reads JSON
documents, so the config is now written with serde_json to the same path.

The one difference: serde_json writes U+007F to U+009F, U+FFFE, and U+FFFF
unescaped, and go-yaml rejects them except U+0085, which it reads as a
space. A config value containing one now fails at boot, or for U+0085
changes the parsed value.
@epompeii
epompeii force-pushed the u/ep/litestream-json branch from fe5086c to 23e8ef5 Compare October 16, 2026 03:42
@epompeii
epompeii marked this pull request as ready for review October 16, 2026 03:43
@epompeii
epompeii merged commit c366cc8 into devel Oct 16, 2026
52 of 53 checks passed
@epompeii
epompeii deleted the u/ep/litestream-json branch October 16, 2026 03:44
epompeii added a commit that referenced this pull request Oct 16, 2026
## Problem

`Lint / Zizmor Online` failed on #1251 (run
https://github.com/bencherdev/bencher/actions/runs/38846843953, job
https://github.com/bencherdev/bencher/actions/runs/38846843953/job/116799199507)
with one medium finding, exit 13:

```
update_sandbox.yml:18: action's hash pin has mismatched or missing version comment: points to commit 683b588c487a
```

Line 18 is
`dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # v1`,
pinned by #1199. The upstream `v1` tag moved to
`683b588c487a69d01f6c6ddf40f036ff682cc2c8` on 2026-10-16. `devel`
carries the same pin, so the job is red on every run since. The job is
`continue-on-error: true`, so it does not block a merge.

## Change

Repin `update_sandbox.yml` to the commit `v1` points at today and keep
the `# v1` comment, as #1199 did. The hash was resolved from the GitHub
refs API (`v1` is a lightweight tag on that commit). No other workflow
or composite action uses this action.

## Upstream range

`e2a55d2f...683b588c` is one commit, "Add 1.99.1 patch release", which
adds `1.99.1` to the patch release list in `scripts/update-revs.sh`.
`action.yml` is unchanged, so this call site (`toolchain: stable`) runs
exactly the same steps.

## Other moving refs

Every other pin whose comment names a moving ref still matches it today:
`rui314/setup-mold@339e96b4 # v1` (14 sites),
`dawidd6/action-download-artifact@b6e2e706 # v21` (2 sites), and
`superfly/flyctl-actions/setup-flyctl@ed8efb33 # master` (3 sites, the
current `master` head). The online pass below proves it.

## Verification

zizmor 1.25.2, the version CI pins, from the same digest-pinned image
`zizmor-action` runs
(`ghcr.io/zizmorcore/zizmor:1.25.2@sha256:14ea7f5c...`), with the
action's arguments (`--persona=regular --format=github`, plus
`--no-online-audits` for the offline job):

| Tree | Offline | Online |
| --- | --- | --- |
| `devel` | exit 0 | exit 13, the one `ref-version-mismatch` finding
above |
| this branch | exit 0 | exit 0, no findings |

CI on this pull request is the final check.
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