Summary
The recent cleanup work made the backend validation split more visible: mdk-memory-storage now uses the shared validation helpers in mdk-storage-traits, but the SQLite backend still has a couple of paths with different acceptance rules.
This is not new behavior, but it leaves SQLite and memory storage out of sync.
Current drift
1) WelcomeStorage::save_welcome()
crates/mdk-memory-storage/src/welcomes.rs calls:
welcomes::validation::validate_welcome_fields(...)
But crates/mdk-sqlite-storage/src/welcomes.rs still validates:
- group name length
- group description length
- serialized JSON size caps
It does not currently run the shared checks for:
- relay count
- per-relay URL length
- admin count
So a welcome can be rejected by memory storage but accepted by SQLite if it stays under the JSON byte caps.
2) GroupStorage::replace_group_relays()
crates/mdk-memory-storage/src/groups.rs uses the shared relay validation helper.
But crates/mdk-sqlite-storage/src/groups.rs::replace_group_relays() still deletes/reinserts rows without first calling:
groups::validation::validate_relay_set(...)
So relay count / relay URL length validation can differ between backends there too.
Desired outcome
Make the backends enforce the same domain rules in these paths by having SQLite call the shared validation helpers before persistence:
welcomes::validation::validate_welcome_fields(...)
groups::validation::validate_relay_set(...)
Keep SQLite-specific serialized-size checks where they are still needed, but run the shared semantic validation first so invalid inputs fail consistently as InvalidParameters instead of only later via storage-specific limits.
Suggested follow-up
Add/adjust regression tests so both backends reject the same invalid inputs for at least:
- welcome relay count
- welcome relay URL length
- welcome admin count
- replace-group-relays relay count
- replace-group-relays relay URL length
Summary
The recent cleanup work made the backend validation split more visible:
mdk-memory-storagenow uses the shared validation helpers inmdk-storage-traits, but the SQLite backend still has a couple of paths with different acceptance rules.This is not new behavior, but it leaves SQLite and memory storage out of sync.
Current drift
1)
WelcomeStorage::save_welcome()crates/mdk-memory-storage/src/welcomes.rscalls:welcomes::validation::validate_welcome_fields(...)But
crates/mdk-sqlite-storage/src/welcomes.rsstill validates:It does not currently run the shared checks for:
So a welcome can be rejected by memory storage but accepted by SQLite if it stays under the JSON byte caps.
2)
GroupStorage::replace_group_relays()crates/mdk-memory-storage/src/groups.rsuses the shared relay validation helper.But
crates/mdk-sqlite-storage/src/groups.rs::replace_group_relays()still deletes/reinserts rows without first calling:groups::validation::validate_relay_set(...)So relay count / relay URL length validation can differ between backends there too.
Desired outcome
Make the backends enforce the same domain rules in these paths by having SQLite call the shared validation helpers before persistence:
welcomes::validation::validate_welcome_fields(...)groups::validation::validate_relay_set(...)Keep SQLite-specific serialized-size checks where they are still needed, but run the shared semantic validation first so invalid inputs fail consistently as
InvalidParametersinstead of only later via storage-specific limits.Suggested follow-up
Add/adjust regression tests so both backends reject the same invalid inputs for at least: