Fix: Guard against negative runtime values in test results#1073
Open
Hell1213 wants to merge 2 commits intoCCExtractor:masterfrom
Open
Fix: Guard against negative runtime values in test results#1073Hell1213 wants to merge 2 commits intoCCExtractor:masterfrom
Hell1213 wants to merge 2 commits intoCCExtractor:masterfrom
Conversation
Add input validation in finish_type_request() to clamp negative runtime values to 0 and log warnings for diagnostics.
e525ded to 3f90041 Compare |
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.



In raising this pull request, I confirm the following (please check boxes):
will of the maintainer.
My familiarity with the project is as follows (check one):
**Fixes ** : #1072
Problem
TestResult.runtime stores the value of runTime from CCExtractorTester without validation. CCExtractorTester can report negative values due to a timestamp calculation bug in that tool. These invalid values were written directly to the database and displayed on test result pages.
Fix
Added input validation in finish_type_request() before constructing the TestResult record. Negative values are clamped to 0 and a warning is logged with the test ID and original value for diagnostic purposes.
Files Changed
mod_ci/controllers.py: validation added in finish_type_request()
tests/test_ci/test_negative_runtime_fix.py: comprehensive test suite
Testing
All existing tests pass
Added 5 test cases covering negative, positive, invalid, zero, and missing runtime values
Verified proper warning logging and value clamping