fix(interactive): resolve --label-column case-insensitively before pre-fill - #513
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A supplied
--label-columnthat matches a CSV header only by case silentlyselected the wrong column.
defaultInOptionsmatches exactly (o == want), so--label-column Incomeagainst a header
incomefailed the match and fell through todefaultLabelChoice, which returns the first column when nothing is namedlabel. The Select then opened on that wrong column and Enter accepted it.Until #505 a supplied
--label-columnskipped the prompt entirely and itsspelling was kept verbatim, so it never had to agree with the header. Making the
question always-ask is what made the mismatch reachable.
canonicalHeaderresolves the supplied value to the header's own spelling beforethe guard runs. Resolving there rather than loosening
defaultInOptionsisdeliberate: that helper also guards
--intentand--label-policyagainst fixedvocabularies, 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 namedlabel):Income→incomeCHURNED→churnedMutation-proved. Reverting the
canonicalHeadercall reddens both, and withexactly the defect's signature:
go test ./...green across all 18 packages;go vetandgofmtclean.Provenance
Found by Bugbot on release-train promotion PR #511 (Medium). Per the staging-hop
policy in release-train's README, findings at
develop -> stagingare fixed onthe source branch rather than ticketed. This unblocks the cli leg of the current
staging hop.
Checklist
developNote
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-columndiffering from the CSV header only by case pre-selected the wrong column in the guided label picker.After #505 always asks the label question,
defaultInOptionsrequires an exact header match, so values likeIncomeagainstincomemissed and fell through todefaultLabelChoice(first column when nolabelcolumn exists).canonicalHeadermaps the supplied flag to the header’s spelling viastrings.EqualFoldbefore that guard; real typos still miss and use the same fallback.defaultInOptionsstays strict for fixed vocabularies (--intent,--label-policy).Tests in
TestPromptLabelColumn_SuppliedDefaultPrefillsAndGuardscoverIncome→incomeandCHURNED→churned.Reviewed by Cursor Bugbot for commit 5dfc323. Bugbot is set up for automated code reviews on this repo. Configure here.