fix: add validation to migrate_recipient_hashes function#722
Open
GazzyLee wants to merge 1 commit into
Open
Conversation
- Add validate_recipient_hash_record() to check schema version integrity - Add validate_recipient_details() to validate bank/wallet fields - Validate existing records before migration to catch corruption early - Return DataCorruption error instead of silently carrying over malformed entries - Ensures migration process maintains data integrity
|
@GazzyLee is attempting to deploy a commit to the Harold's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@GazzyLee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
The
migrate_recipient_hashesfunction insrc/recipient_verification.rsmigrates records to the new schema version without validating that existing records are well-formed. Corrupted records are silently carried over to the new schema, potentially causing issues downstream.Solution
Added comprehensive validation checks during the migration process to detect and reject malformed entries early.
Changes
New Validation Functions
validate_recipient_hash_record(record: &RecipientHashRecord) -> Result<(), ContractError>Validates the integrity of existing hash records before migration:
DataCorruptionerror for invalid recordsvalidate_recipient_details(details: &RecipientDetails) -> Result<(), ContractError>Validates new recipient details before storing migrated hashes:
AddresstypeDataCorruptionerror for invalid detailsModified Functions
migrate_recipient_hashes()Before:
After:
validate_recipient_hash_record()on existing recordsvalidate_recipient_details()on new detailsDataCorruptionerror on validation failure (fail-fast approach)Benefits
✅ Data Integrity: Catches and rejects corrupted records during migration
✅ Fail-Fast: Stops migration immediately upon detecting malformed entries
✅ Clear Error Handling: Returns explicit
DataCorruptionerror instead of silently proceeding✅ Comprehensive Validation: Covers both existing records and new details
✅ Documented: Clear validation logic with comments explaining the checks
Testing Recommendations
DataCorruption)DataCorruption)DataCorruption)DataCorruption)Breaking Changes
None. The function signature remains unchanged. Existing valid migrations will continue to work, but corrupted migrations will now fail with
DataCorruptionerror instead of succeeding silently.Related Issues
Fixes the data corruption vulnerability in recipient hash schema migration.
Checklist
fix/recipient-hash-validationCloses #614