Skip to content

normalizeTestPhase(undefined) silently defaults to 'provisional' — EXAMPLE and SYSTEM score rows with missing metadata incorrectly counted as provisional #48

Description

@FedorPortnoi

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

  1. EXAMPLE-phase score records with missing testType metadata are counted toward provisional totals
  2. SYSTEM-phase score records with missing testType metadata are counted toward provisional totals
  3. EXAMPLE and SYSTEM phase score totals are under-counted
  4. Provisional totals are over-counted, potentially changing final standings
  5. Data integrity issues (missing testType) are silently absorbed rather than surfaced, making them impossible to detect without manual database inspection

Steps to Reproduce

  1. Submit a solution that produces scoring results
  2. 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)
  3. Re-query phase-separated score totals
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions