Skip to content

fix(interactive): resolve --label-column case-insensitively before pre-fill - #513

Merged
LukasWodka merged 1 commit into
developfrom
fix/label-column-case-prefill
Aug 15, 2026
Merged

fix(interactive): resolve --label-column case-insensitively before pre-fill#513
LukasWodka merged 1 commit into
developfrom
fix/label-column-case-prefill

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

A supplied --label-column that matches a CSV header only by case silently
selected the wrong column.

defaultInOptions matches exactly (o == want), so --label-column Income
against a header income failed the match and fell through to
defaultLabelChoice, which returns the first column when nothing is named
label. The Select then opened on that wrong column and Enter accepted it.

Until #505 a supplied --label-column skipped the prompt entirely and its
spelling was kept verbatim, so it never had to agree with the header. Making the
question always-ask is what made the mismatch reachable.

canonicalHeader resolves the supplied value to the header's own spelling before
the guard runs. Resolving there rather than loosening defaultInOptions is
deliberate: that helper also guards --intent and --label-policy against fixed
vocabularies, which should stay exact matches. A value matching nothing is
returned unchanged, so a genuine typo still falls back rather than being
case-folded into a hit.

Type

fix

Test plan

Two rows added to TestPromptLabelColumn_SuppliedDefaultPrefillsAndGuards
(fixture header age,income,churned, no column named label):

  • Incomeincome
  • CHURNEDchurned

Mutation-proved. Reverting the canonicalHeader call reddens both, and with
exactly the defect's signature:

promptLabelColumn(supplied="Income")  = "age", want "income"
promptLabelColumn(supplied="CHURNED") = "age", want "churned"

go test ./... green across all 18 packages; go vet and gofmt clean.

Provenance

Found by Bugbot on release-train promotion PR #511 (Medium). Per the staging-hop
policy in release-train's README, findings at develop -> staging are fixed on
the source branch rather than ticketed. This unblocks the cli leg of the current
staging hop.

Checklist

  • Targets develop
  • Single self-contained change
  • Tests added and mutation-proved
  • No secrets or customer data

Note

Low Risk
Narrow interactive CLI pre-fill fix with targeted tests; no changes to ingest validation or server-side label handling.

Overview
Fixes a regression where --label-column differing from the CSV header only by case pre-selected the wrong column in the guided label picker.

After #505 always asks the label question, defaultInOptions requires an exact header match, so values like Income against income missed and fell through to defaultLabelChoice (first column when no label column exists). canonicalHeader maps the supplied flag to the header’s spelling via strings.EqualFold before that guard; real typos still miss and use the same fallback. defaultInOptions stays strict for fixed vocabularies (--intent, --label-policy).

Tests in TestPromptLabelColumn_SuppliedDefaultPrefillsAndGuards cover Incomeincome and CHURNEDchurned.

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

…e-fill

defaultInOptions matches exactly, so a --label-column differing from the CSV
header only in case failed the match and fell through to defaultLabelChoice --
the FIRST column when nothing is named "label". Enter then accepted that wrong
column silently.

Until #505 a supplied --label-column skipped the prompt entirely and its
spelling was kept verbatim, so it never had to agree with the header. Now that
the question is always asked, the mismatch became reachable.

canonicalHeader resolves the supplied value to the header's own spelling before
the guard. Resolving there rather than loosening defaultInOptions keeps the
case-insensitivity where the options are user data -- defaultInOptions also
guards --intent and --label-policy against fixed vocabularies, which should
stay exact. A value matching nothing is returned unchanged, so a genuine typo
is still caught rather than case-folded into a hit.

Mutation-proved: reverting the canonicalHeader call reddens both new rows with
"Income" -> "age" and "CHURNED" -> "age", the defect verbatim.

Found by Bugbot on release-train promotion PR cli#511.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@LukasWodka LukasWodka self-assigned this Aug 15, 2026
@LukasWodka
LukasWodka requested a review from saadqbal August 15, 2026 08:03
@LukasWodka
LukasWodka merged commit 5ad2a0e into develop Aug 15, 2026
28 checks passed
@LukasWodka
LukasWodka deleted the fix/label-column-case-prefill branch August 15, 2026 08:45
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