Skip to content

fix(generate): only block genuinely headerless .wgt.csv at generate-level#197

Merged
ake2l merged 2 commits into
developmentfrom
fix/wgt-csv-generate-guard-headered
Jul 6, 2026
Merged

fix(generate): only block genuinely headerless .wgt.csv at generate-level#197
ake2l merged 2 commits into
developmentfrom
fix/wgt-csv-generate-guard-headered

Conversation

@ake2l

@ake2l ake2l commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

  • fix(generate): fail loudly on a headerless .wgt.csv source, don't misparse it #194 blocked ALL `.wgt.csv` at ``-level, merged before feat(csv): .wgt.csv accepts an optional header row #196 (`.wgt.csv` accepts an optional header) landed. That makes it too strict now: a HEADERED `.wgt.csv` reads coherently through the plain CSV path (proper column names, just unweighted) - the same tolerance `.wgt.ent.csv` already gets. Only a genuinely headerless `.wgt.csv` has no coherent plain-CSV reading at all (first data row misread as a header, producing nonsense column names).
  • Narrowed the guard to sniff the file's own first row (same check `FileUtil.read_weight_csv` itself uses to auto-detect a header) and only raise when there is no header to fall back on.

Test plan

  • Headerless `.wgt.csv` at ``-level still raises.
  • New: headered `.wgt.csv` at ``-level now reads through (unweighted, coherent columns) instead of raising.
  • `.wgt.ent.csv` regression test still passes.
  • Full suite: 1442 passed, 15 skipped, mypy/ruff clean.

ake2l added 2 commits July 6, 2026 18:39
…evel

#194 blocked ALL .wgt.csv at <generate>-level, merged before #196 (.wgt.csv
accepts an optional header) landed. That makes it too strict now: a HEADERED
.wgt.csv reads coherently through the plain CSV path (proper column names,
just unweighted) - the same tolerance .wgt.ent.csv already gets. Only a
genuinely headerless .wgt.csv has no coherent plain-CSV reading at all (first
data row misread as a header, producing nonsense column names).

Narrowed the guard to sniff the file's own first row (same check
FileUtil.read_weight_csv itself uses to auto-detect a header) and only raise
when there is no header to fall back on.

Full suite 1442 passed/15 skipped, mypy/ruff clean.
_wgt_csv_has_header re-implemented the same float-parse try/except
FileUtil._parses_as_float (from #196) already provides. One sniff, not two.
@ake2l
ake2l merged commit d811422 into development Jul 6, 2026
11 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant