Skip to content

Improve TOML serialization error message for unsupported types#880

Merged
max-sixty merged 1 commit intomitsuhiko:masterfrom
max-sixty:toml
Feb 26, 2026
Merged

Improve TOML serialization error message for unsupported types#880
max-sixty merged 1 commit intomitsuhiko:masterfrom
max-sixty:toml

Conversation

@max-sixty
Copy link
Collaborator

Summary

  • Replace bare .unwrap() in TOML serialization with an informative panic that shows the original toml_edit error and explains TOML's top-level struct/map requirement
  • Add test for top-level sequence case (issue assert_toml_snapshot seems broken #879)
  • Update existing unit struct test to match the improved error text

Closes #879. Thanks to @ip1981 for reporting.

Before:

called `Result::unwrap()` on an `Err` value: UnsupportedType(None)

After (top-level sequence):

TOML serialization failed: unsupported rust type. Note: TOML requires the
top-level value to be a struct or map. Use assert_json_snapshot! or
assert_yaml_snapshot! for other types.

After (unsupported inner type):

TOML serialization failed: unsupported Marker type. Note: TOML requires the
top-level value to be a struct or map. Use assert_json_snapshot! or
assert_yaml_snapshot! for other types.

Test plan

  • New test_toml_top_level_sequence_unsupported test verifies the error message
  • Existing test_toml_unit_struct_unsupported updated to match improved text
  • All 34 TOML tests pass
  • Full test suite passes

This was written by Claude Code on behalf of @max-sixty

Replace bare `.unwrap()` with an informative error that shows the
original `toml_edit` error and explains TOML's top-level struct/map
requirement.

Closes mitsuhiko#879

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit 09f2b8b into mitsuhiko:master Feb 26, 2026
15 checks passed
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.

assert_toml_snapshot seems broken

1 participant