add accepts Infinity scores and writes records that immediately fail validation

Offen Anfängerfreundlich
#69 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@vivek-3728 arbeitet bereits daran.

Seit 01.11.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
76/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
cli

Rechercherichtung

Beginne damit, das Parsen und die Validierung von score und max_score im Befehl add zu finden, und vergleiche dann dessen Prüfungen mit den numerischen Regeln des Befehls validate. Führe die angegebenen CLI-Befehle mit einer temporären CSV-Datei aus und sieh dir die relevanten Tests an. Ziel ist, dass add nicht endliche Werte zurückweist, ohne einen Datensatz zu schreiben, und dass akzeptierte Datensätze validate bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

good first issue
Description

I found a bug where the add command accepts inf as both the score and maximum score, even though these are not valid numeric grades.

The command reports success and writes the record to the CSV, but running validate immediately afterward rejects the same record.

This means a normal add operation can turn an otherwise valid grade file into one that fails the application's own validation.

Steps to Reproduce

Run:

python -m grade_tracker --data grades.csv add S1 Math inf inf 2026-10-30 3 1
python -m grade_tracker --data grades.csv validate
Actual Behavior

The add command reports:

Added grade for S1 in Math.

The CSV now contains:

S1,Math,inf,inf,2026-10-30,3.0,1

However, validation reports:

Error: row 2, field score: 'inf' is not a numeric score
Error: row 2, field max_score: 'inf' is not a numeric maximum score
Validation failed: 2 problems found.
Expected Behavior

The add command should reject non-finite values before writing anything to the CSV.

Any record successfully added through the CLI should also pass the application's numeric validation rules.

Likely Cause

The add command relies on numeric range comparisons without explicitly checking whether the values are finite.

Since Python evaluates float("inf") <= float("inf") as True, the invalid values pass the existing checks.

The validation command applies stricter numeric rules and correctly rejects them.

Using math.isfinite() for both score and max_score would prevent Infinity and NaN values from being accepted.

Impact

A successful CLI operation can introduce invalid grade records into an otherwise valid CSV file.

This creates inconsistent behavior between add and validate and may affect subsequent calculations, reporting, or exports.

The issue was reproduced on the latest upstream/main and no matching report was found among the 68 open and closed issues and PRs checked.

Vorherrschende Sprache
Python
Sterne
0
Forks
5
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
27

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus techcsispit/grade-tracker

Alle Issues in techcsispit/grade-tracker

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.