Summary
The phase normalization logic in scoring-result.service.ts maps the metadata.testType value of a scoring result to a canonical phase name. When testType is undefined or missing, the function silently defaults to 'provisional'. Score records for EXAMPLE and SYSTEM test runs that are missing their testType metadata are therefore silently attributed to the provisional phase, inflating provisional totals and under-counting EXAMPLE and SYSTEM phase scores.
Affected File
src/api/scoring-result/scoring-result.service.ts, lines 983–1007
function normalizeTestPhase(testType: string | undefined): string {
if (!testType) return 'provisional'; // ← silent default — masks data integrity issues
switch (testType) {
case 'example': return 'example';
case 'system': return 'system';
default: return 'provisional';
}
}
Impact
- EXAMPLE-phase score records with missing
testType metadata are counted toward provisional totals
- SYSTEM-phase score records with missing
testType metadata are counted toward provisional totals
- EXAMPLE and SYSTEM phase score totals are under-counted
- Provisional totals are over-counted, potentially changing final standings
- Data integrity issues (missing
testType) are silently absorbed rather than surfaced, making them impossible to detect without manual database inspection
Steps to Reproduce
- Submit a solution that produces scoring results
- Manually set
metadata.testType to null or remove it on any score record in the database (simulating a write failure or a scorer that omits the field)
- Re-query phase-separated score totals
- Observe the record is counted under provisional rather than being flagged or orphaned
Expected
normalizeTestPhase(undefined) should throw an error or return a sentinel value that causes the affected records to be excluded or flagged for investigation — not silently reassigned to provisional. Missing phase metadata is a data integrity problem that should surface as an observable error.
Severity: Low-Medium
Summary
The phase normalization logic in
scoring-result.service.tsmaps themetadata.testTypevalue of a scoring result to a canonical phase name. WhentestTypeisundefinedor missing, the function silently defaults to'provisional'. Score records for EXAMPLE and SYSTEM test runs that are missing theirtestTypemetadata are therefore silently attributed to the provisional phase, inflating provisional totals and under-counting EXAMPLE and SYSTEM phase scores.Affected File
src/api/scoring-result/scoring-result.service.ts, lines 983–1007Impact
testTypemetadata are counted toward provisional totalstestTypemetadata are counted toward provisional totalstestType) are silently absorbed rather than surfaced, making them impossible to detect without manual database inspectionSteps to Reproduce
metadata.testTypetonullor remove it on any score record in the database (simulating a write failure or a scorer that omits the field)Expected
normalizeTestPhase(undefined)should throw an error or return a sentinel value that causes the affected records to be excluded or flagged for investigation — not silently reassigned to provisional. Missing phase metadata is a data integrity problem that should surface as an observable error.Severity: Low-Medium