Avoid client errors when a new variant of `MultiFilesUri` is added

Open
#3,587 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
blockchain, cli

Research direction

Start at the MultiFilesUri definition and compare its serialization behavior with the signed entity types’ custom serde approach. Trace how locations are handled in the client library and client CLI, then run or add unit tests for known and unknown variants and the golden test for a message containing an unknown variant. Done means unsupported locations are skipped without deserialization errors while known variants continue to work.

Written by the indexing model from the issue text.

Description

optimization :hammer_and_wrench: to-groom :thinking:

Why

MultiFilesUri only has the Template variant and is deserialized with the derived serde implementation, so adding a new variant on the aggregator side would make already released clients fail to deserialize the Cardano database messages.

What

Make the deserialization of MultiFilesUri tolerant to unknown variants, so that a client ignores the locations it does not support instead of failing.

How

  • Add a catch-all variant to MultiFilesUri for the unknown variants
  • Implement a custom serde deserialization that maps any unknown variant to the catch-all (same approach as SignedEntityTypeMessage, as #[serde(other)] only supports unit variants)
  • Make expand_to_file_uri and expand_for_immutable_file_number of MultiFilesUri return an error for the catch-all variant
  • Skip the locations with an unknown URI variant in ImmutablesMessagePart::sanitized_locations, so that the client library and the client CLI ignore them
  • Add a golden test with a message that holds an unknown varian
Dominant language
Rust
Stars
155
Forks
52
Avg merge
2d 17h
Merged PRs (30d)
37

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IntersectMBO/mithril

All issues in IntersectMBO/mithril

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.