Skip to content

Replace serde_yaml with serde_norway (#1937) - #2532

Merged
Archigos merged 3 commits into
espanso:devfrom
gcailly:feature/replace-serde-yaml-with-serde-norway
Dec 9, 2025
Merged

Archigos merged 3 commits into
espanso:devfrom
gcailly:feature/replace-serde-yaml-with-serde-norway

Conversation

@gcailly

@gcailly gcailly commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

This PR migrates from the deprecated serde_yaml to the actively maintained serde_norway.

  • Updated workspace dependency: serde_yaml = "0.8.17" → serde_norway = "0.9.42".
  • Replaced all serde_yaml imports with serde_norway across the codebase (15 files).
  • Added handling for serde_norway::Value::Tagged variant (new feature for YAML custom tags).

Fixes #1937

- Allow offset parameter to accept String in addition to Number
- Enables variable injection like offset: '{{hours_offset}}'
- Parse string offset to i64, ignore if invalid (no error)
- Add test for string offset: offset_with_string_works
- Add test for invalid string offset: offset_with_invalid_string_is_ignored
- Update JSON schema to accept ['number', 'string'] for offset
- Maintains full backward compatibility with numeric offsets
Migrated from the deprecated serde_yaml (v0.8.17) to the actively
maintained serde_norway (v0.9.42).

serde_norway is a hard-fork of serde_yaml maintained by the original
author David Tolnay along with Christina Sørensen. It provides full
API compatibility while being actively maintained with regular updates.

Changes:
- Updated workspace dependency from serde_yaml to serde_norway
- Replaced all serde_yaml imports with serde_norway across codebase
- Added handling for serde_norway::Value::Tagged variant
- All tests pass (202 tests) and cargo clippy reports no warnings

Fixes espanso#1937
@gcailly
gcailly requested a review from AucaCoyan as a code owner October 12, 2025 13:32
@gcailly
gcailly marked this pull request as draft October 12, 2025 16:52
@gcailly

gcailly commented Oct 12, 2025 •

Copy link
Copy Markdown
Contributor Author

I naively thought that solving #1937 would be simple. However, finding a replacement library is proving difficult. I really lack knowledge of the ecosystem.

Some alternatives :

  • serde_yaml_ng : 120,899 downloads per month, used in 71 crates. Last update May 26, 2024, last commit Jul 9, 2025.
  • serde_yaml_bw : 2,282 downloads per month, used in 5 crates. Last update Oct 3, 2025.
  • serde_yml : 845,475 downloads per month, used in 298 crates. Last update Aug 25, 2024. But seems to have bad reviews, and made by a fool with AI like me 😅.
  • serde_norway : 276,309 downloads per month (but only recently), used in 62 crates. Last update Dec 21, 2024 (but maintainer is Christina Sørensen and she responded to an issue in June).

I picked the last one, but I'm getting a bit carried away and this PR is a suggestion. 🙂

@gcailly
gcailly marked this pull request as ready for review October 12, 2025 19:25
@AucaCoyan

Copy link
Copy Markdown
Collaborator

Thanks for the investigation!
I knew that the yaml crates were a minefield and also left to the darker corner of crates. Perhaps that is why I stalled updating the yaml crate for so long 😆 .
I appreciate the effort to put links for everything, it's easier to follow up on present and future state of the crates!

@AucaCoyan
AucaCoyan requested review from Archigos and removed request for AucaCoyan December 9, 2025 13:47
@Archigos
Archigos merged commit ea221a7 into espanso:dev Dec 9, 2025
sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
…ml-with-serde-norway

Replace `serde_yaml` with `serde_norway` (espanso#1937)
YuriNachos added a commit to YuriNachos/espanso that referenced this pull request Aug 8, 2026
Restore the pre-2.4.0 (serde_yaml) tolerance for unquoted flow-collection
values that start with a YAML flow indicator (`:`, `>`, `|`), e.g.
`triggers: [:->,:>-]`, which PR espanso#2532 (serde_yaml -> serde_norway) broke.
serde_norway is libyaml-based and rejects such scalars with
"did not find expected node content ... while parsing a flow node".

Add a pure `lenient_flow_quote` helper applied only on retry-on-failure: the
strict parse is tried first, so every config that parses today is returned
byte-for-byte untouched. The fix covers both YAMLMatchGroup and YAMLConfig
parse entry points via a shared `parse_lenient<T>` wrapper in `util`.

`|`/`>` block-scalar bodies (e.g. a multi-line `replace: |` whose literal
text contains `[ ... ]`) are detected and copied verbatim, so the transform
never re-quotes inside them.

Fixes espanso#2748

Co-Authored-By: Claude <[email protected]>
AucaCoyan added a commit that referenced this pull request Sep 1, 2026
…ons (#2761)

* fix(config): parse unquoted special-char values in YAML flow collections

Restore the pre-2.4.0 (serde_yaml) tolerance for unquoted flow-collection
values that start with a YAML flow indicator (`:`, `>`, `|`), e.g.
`triggers: [:->,:>-]`, which PR #2532 (serde_yaml -> serde_norway) broke.
serde_norway is libyaml-based and rejects such scalars with
"did not find expected node content ... while parsing a flow node".

Add a pure `lenient_flow_quote` helper applied only on retry-on-failure: the
strict parse is tried first, so every config that parses today is returned
byte-for-byte untouched. The fix covers both YAMLMatchGroup and YAMLConfig
parse entry points via a shared `parse_lenient<T>` wrapper in `util`.

`|`/`>` block-scalar bodies (e.g. a multi-line `replace: |` whose literal
text contains `[ ... ]`) are detected and copied verbatim, so the transform
never re-quotes inside them.

Fixes #2748

Co-Authored-By: Claude <[email protected]>

* fix clippy lints

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Auca Maillot <[email protected]>
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.

Replace serde_yaml for a maintained crate

3 participants