Skip to content

fix(snapshot): preserve legacy function snapshot deserialization - #1467

Merged
chaliy merged 1 commit into
mainfrom
2026-04-24-propose-fix-for-legacy-snapshot-restore-issue
Apr 25, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-04-24-propose-fix-for-legacy-snapshot-restore-issue

Conversation

@chaliy

@chaliy chaliy commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Legacy snapshots that stored function entries as raw FunctionDef stopped restoring because the new untagged enum attempted the new wrapper form first and optional fields allowed legacy objects to be misparsed as an empty wrapper.
  • Restore backward compatibility so older snapshots can still be deserialized and functions restored.

Description

  • Add #[serde(deny_unknown_fields)] to SnapshottedFunction so objects with legacy FunctionDef fields do not deserialize into the wrapper and instead match the Legacy(FunctionDef) variant.
  • Add regression test snapshot_restores_legacy_function_shape_without_wrapper to assert a legacy-format function entry roundtrips and is registered on restore.
  • Tighten the existing source-only restore test to assert the function is actually registered (type greet) before invoking it.

Testing

  • Ran cargo fmt --check which succeeded.
  • Ran cargo test -p bashkit --test snapshot_tests snapshot_preserves_functions -- --exact which passed.
  • Ran cargo test -p bashkit --test snapshot_tests snapshot_restores_functions_from_source_when_ast_missing -- --exact which passed.
  • Ran cargo test -p bashkit --test snapshot_tests snapshot_restores_legacy_function_shape_without_wrapper -- --exact which passed.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 687056f Commit Preview URL Apr 25 2026, 02:55 AM

@chaliy
chaliy force-pushed the 2026-04-24-propose-fix-for-legacy-snapshot-restore-issue branch from f9fcd0b to 687056f Compare April 25, 2026 02:55
@chaliy
chaliy merged commit 2fd6af0 into main Apr 25, 2026
34 checks passed
@chaliy
chaliy deleted the 2026-04-24-propose-fix-for-legacy-snapshot-restore-issue branch April 25, 2026 03:04
@codecov

codecov Bot commented Apr 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

chaliy added a commit that referenced this pull request May 30, 2026
### Motivation
- Legacy snapshots that stored function entries as raw `FunctionDef`
stopped restoring because the new untagged enum attempted the new
wrapper form first and optional fields allowed legacy objects to be
misparsed as an empty wrapper.
- Restore backward compatibility so older snapshots can still be
deserialized and functions restored.

### Description
- Add `#[serde(deny_unknown_fields)]` to `SnapshottedFunction` so
objects with legacy `FunctionDef` fields do not deserialize into the
wrapper and instead match the `Legacy(FunctionDef)` variant.
- Add regression test
`snapshot_restores_legacy_function_shape_without_wrapper` to assert a
legacy-format function entry roundtrips and is registered on restore.
- Tighten the existing source-only restore test to assert the function
is actually registered (`type greet`) before invoking it.

### Testing
- Ran `cargo fmt --check` which succeeded. 
- Ran `cargo test -p bashkit --test snapshot_tests
snapshot_preserves_functions -- --exact` which passed.
- Ran `cargo test -p bashkit --test snapshot_tests
snapshot_restores_functions_from_source_when_ast_missing -- --exact`
which passed.
- Ran `cargo test -p bashkit --test snapshot_tests
snapshot_restores_legacy_function_shape_without_wrapper -- --exact`
which passed.

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_69eaf1c5cbd0832bbada3f4852597d1f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant