fix(migrate): handle legacy periods outside millisecond range - #52
Closed
albertovincenzi wants to merge 1 commit into
Closed
fix(migrate): handle legacy periods outside millisecond range#52albertovincenzi wants to merge 1 commit into
albertovincenzi wants to merge 1 commit into
Conversation
Contributor
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.
Dipendenza
Questa PR è impilata su #43. Dopo la migrazione, il
PUTcostruisce anche le warning del documento v2; #43 rende sicuro quel secondo passaggio per lo stesso valore estremo.Problema
Il wire v1 rappresenta
periodSecondscon uni64; il wire v2 rappresentatimeMsancora con uni64. La migrazione faceva direttamenteperiodSeconds * 1000, quindi un documento v1 JSON valido soprai64::MAX / 1000:2 * count.Il risultato era un errore di processo durante un percorso che promette di leggere documenti legacy.
Fix
saturating_mul;period-clampedquando il tipo v2 non può rappresentare il periodo originale;2 × countmostrati nella warning;periodSeconds = i64::MAXe count estremo, includendo il successivo passaggiowarnings().Test
cargo test -p gate-core(97 test + doc-test, tutti verdi);cargo clippy -p gate-core --all-targets -- -D warnings;cargo fmt --all -- --check;git diff --check.Per Alice
Il trade-off da valutare è esplicito: v2 non può rappresentare in millisecondi l'intero range in secondi di v1. Questa PR conserva la promessa di migrazione totale, limita il valore al massimo rappresentabile e rende la perdita di range visibile al caller. L'alternativa sarebbe rifiutare questi soli documenti legacy; sarebbe più rigida ma romperebbe la compatibilità dichiarata in §12.1.