Decide a replay is too short before registering its match - #132
Open
bill-rich wants to merge 1 commit into
Open
Conversation
upload_replay registered the match, computed its composition and invalidated the caches, and only then asked match_from_replay whether the replay was long enough to count, raising 422 when it wasn't. The writes had already happened, so a short game ended up half-present: reachable through /api/details and /api/replays, absent from /api/matches/by_date (get_match_infos lists with a 2.0 minute floor), and reported to the uploading client as a plain failure. Match 866608453 from 2026-08-21 is one of these, a 42 second game someone quit out of. cncstats holds stats for it, radarvan answers /api/details for it, and it appears in no date listing. Run the validation first and register nothing when it fails. The parsed .rep and .json are still persisted by upload_and_parse, so the artifact survives either way; only the match row is now conditional, which matches what every read path already assumes.
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.
What
upload_replayregistered the match, computed its composition and invalidated the caches, and only then askedmatch_from_replaywhether the replay was long enough to count, raising 422 when it wasn't:The writes had already happened by the time we decided the upload was invalid, so a short game landed half-present: reachable through
/api/detailsand/api/replays, absent from/api/matches/by_date(get_match_infoslists with a 2.0 minute floor), and reported to the uploading client as a flat failure.Match
866608453from 2026-08-21 is a live example: a 42 second game someone quit out of. cncstats holds stats for it, radarvan answers/api/details/866608453, and it shows up in no date listing. It also makes "did every match land?" reconciliation between the two servers lie.Change
Run the validation before any write, and register nothing when it fails. The parsed
.repand.jsonare still persisted byupload_and_parse, so the raw artifact survives either way; only the match row becomes conditional, which is what every read path already assumes.Testing
New
tests/test_upload_replay.pypins the ordering: a short replay must leaveregister_match/compute_and_save_compositionuncalled, and a normal one must still register. Verified the first test fails against the old ordering and passes with the fix.Full suite: 226 passed, 5 skipped.
ruff check radarvan/andmypy radarvan/clean.