Skip to content

Bug 1929903 - Preserve object property names in Rust JSON - #890

Merged
badboy merged 3 commits into
mozilla:mainfrom
akasakariko:bug-1929903-object-field-names
Nov 4, 2026
Merged

badboy merged 3 commits into
mozilla:mainfrom
akasakariko:bug-1929903-object-field-names

Conversation

@akasakariko

@akasakariko akasakariko commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Object properties such as foo.bar-baz become Rust fields such as foo_bar_baz without a Serde rename, causing serialization to emit the wrong JSON key and deserialization to reject the original schema key

Always add Serde renames in the Rust and Rust Sym object templates while retaining the existing Rust field names, including fields whose names already match the schema

Extend the existing object test to cover dots, hyphens, uppercase names, nested objects, arrays, union properties, and an unchanged snake_case property

Bug 1929903: https://bugzilla.mozilla.org/show_bug.cgi?id=1929903

Firefox’s separate generator patch: https://phabricator.services.mozilla.com/D338979

Validation on afa0dd058c1d7009670cc0fd5afad545dba6b5f6, after merging upstream main at dc9ff80a8b1b9fb67fe8d7d8a57f3faa6a7c842c:

  • Rust and Rust Sym tests: 12 passed
  • Default pytest suite: 312 passed, 25 skipped
  • Ruff check and format, yamllint, mypy, license check, and git diff --check: passed
  • Standalone Serde checks using structs generated by the Rust, Rust Sym, and Firefox template macros: 12 passed, covering original keys, round trips, rejection of normalized keys, and omission behavior
  • GitHub CI for the current commit: all 12 jobs passed, including Python 3.9–3.14, minimum dependency versions, docs, lint, license checks, and security analysis
  • All seven CI Python configurations ran make test-full and reported 337 passed; the documentation build passed with 9 warnings
  • The optional full suite was not rerun locally; full SDK integration and browser end-to-end tests have not been run

Pull Request checklist

  • Quality: Local tests and all GitHub CI jobs passed for the current commit
    • Existing deprecation warnings remain
  • Tests: The existing object test covers renamed and unchanged property names in both Rust generators
  • Changelog: Added an entry to CHANGELOG.md; Rust field names remain unchanged

Add conditional Serde renames when schema properties differ from their
generated Rust fields in the Rust and Rust Sym templates

Extend the existing object test to cover original JSON keys for dotted,
hyphenated, uppercase, nested, array, and union properties
@akasakariko
akasakariko requested a review from a team as a code owner November 3, 2026 00:09
@akasakariko
akasakariko requested review from badboy and removed request for a team November 3, 2026 00:09
Comment thread glean_parser/templates/rust.jinja2 Resolved
@badboy
badboy merged commit 1cbae9b into mozilla:main Nov 4, 2026
12 checks passed
akasakariko added a commit to akasakariko/akasakariko that referenced this pull request Nov 4, 2026
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