Skip to content

fix(push): text preflight fails closed on a labels.csv read error - #221

Merged
saadqbal merged 1 commit into
developfrom
fix/text-preflight-unparseable-row
Jul 10, 2026
Merged

fix(push): text preflight fails closed on a labels.csv read error#221
saadqbal merged 1 commit into
developfrom
fix/text-preflight-unparseable-row

Conversation

@saadqbal

@saadqbalsaadqbal commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What

manifestReferencedTextNames (enforced-text preflight) skipped a failed labels.csv read with continue, returning a partial referenced set — so the text files named by the unread rows would silently escape the enforced record-format check (local fail-open). A persistent read error would also spin the loop forever.

The image mirror-check CrossCheckLabels already aborts on the same read error; this makes the enforced-text path match and fail closed.

Bugbot framing vs. reality

Bugbot flagged this as "skips bad CSV rows." That specific scenario isn't reproducible: openCSVReader sets LazyQuotes + FieldsPerRecord=-1, so every malformed CSV shape (bare/unbalanced quotes, ragged rows, null bytes, stray CR) parses cleanly — exactly like pandas. Verified empirically. The err != nil branch is therefore reachable only via a genuine I/O read error, not content. The fix is still correct (fail closed + consistent with the image sibling + removes the latent infinite loop); the code comment and test say so honestly rather than repeating the "bad row" framing.

Test

The branch can't be hit through a real file, so the parse loop is split into referencedTextNames(*csv.Reader) and exercised with an injected reader that yields the header then fails — asserting the walk returns the wrapped read error instead of a partial set.

Scope

Bugbot drive-by on promote PR #219; rolls up under release ticket #220 (no separate kanban item). Targets develop so it joins the v0.8.0 payload before staging QA.

🤖 Generated with Claude Code


Note

Medium Risk
Changes local dataset preflight validation for enforced text record formats; incorrect behavior could let some manifest-referenced files skip checks, but the change tightens fail-closed behavior to match existing image preflight.

Overview
Enforced-text preflight no longer keeps walking labels.csv when a row read fails with a real I/O error. It now aborts and returns a wrapped reading labels.csv error, matching how CrossCheckLabels handles the same failure for image layouts.

The manifest walk is split into referencedTextNames(*csv.Reader) so that behavior can be tested without a real file. A test uses an injected reader that serves the header then fails mid-stream, asserting discovery does not return a partial referenced filename set (which would skip validation for unread rows).

Comments clarify that with LazyQuotes and FieldsPerRecord=-1, malformed CSV rows are not what hit this branch—only genuine read failures do.

Reviewed by Cursor Bugbot for commit 1831a54. Bugbot is set up for automated code reviews on this repo. Configure here.

…reflight)
manifestReferencedTextNames skipped a failed CSV read with `continue`,
returning a partial referenced set — so the text files named by the
unread rows would silently escape the enforced record-format check
(local fail-open), and a *persistent* read error would spin the loop
forever. The image mirror-check (CrossCheckLabels) already aborts on the
same read error; make the enforced-text path match and fail closed.
The trigger is I/O, not malformed CSV content: openCSVReader sets
LazyQuotes + FieldsPerRecord=-1, so every bad CSV shape parses cleanly
(like pandas) — the branch is only reachable via a genuine read failure.
The parse loop is split into referencedTextNames(*csv.Reader) so that
branch can be exercised with an injected failing reader.
Addresses the Bugbot finding on #219.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saadqbal
saadqbal merged commit e1ea845 into developJul 10, 2026
20 checks passed
@saadqbal
saadqbal deleted the fix/text-preflight-unparseable-row branch July 10, 2026 15:16
saadqbal added a commit that referenced this pull request Jul 10, 2026
…preflight (#222)
Two more mirror-checks swallowed a non-EOF csv.Reader.Read error with
`continue`, same class as #221:
- readLabelColumnValues (CheckLabelDiversity / ReadLabelValues): a
mid-read failure returned a PARTIAL class set with Found=true —
under-counting classes could false-reject good data or pass a bad
file. Now returns an error; the diversity GATE fails closed, while the
value PREVIEW (ReadLabelValues) degrades to Found=false.
- CheckSequenceRows: a mid-read failure skipped the unread tail, so
null/missing sequence ids there never surfaced locally. Now fails
closed.
CrossCheckLabels and the tabular schema scan already abort on the same
error; this brings the whole package to uniform fail-closed behavior.
The trigger is I/O, not malformed CSV (LazyQuotes + FieldsPerRecord=-1
tolerate every bad shape). Each scan is split into a reader-based core
(labelColumnValuesFrom / sequenceScanFrom) so the branch is exercised
with an injected failing reader; parsing is unchanged and the value
parity harness validates the relocation.
Addresses the two follow-up Bugbot findings on #219.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto 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.

2 participants

@saadqbal@LukasWodka