Skip to content

Fix: Guard against negative runtime values in test results#1073

Open
Hell1213 wants to merge 2 commits intoCCExtractor:masterfrom
Hell1213:feature/issue-1072-negative-runtime
Open

Fix: Guard against negative runtime values in test results#1073
Hell1213 wants to merge 2 commits intoCCExtractor:masterfrom
Hell1213:feature/issue-1072-negative-runtime

Conversation

@Hell1213
Copy link
Contributor

@Hell1213 Hell1213 commented Mar 22, 2026

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the
    will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows (check one):

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

**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

Add input validation in finish_type_request() to clamp negative runtime values to 0 and log warnings for diagnostics.
@Hell1213 Hell1213 force-pushed the feature/issue-1072-negative-runtime branch from e525ded to 3f90041 Compare March 22, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant