Skip to content

fix(rename): clarify missing column errors - #19609

Merged
fdncred merged 3 commits into
nushell:mainfrom
manavkdubey:investigate/rename-column-17448
Nov 20, 2026
Merged

fdncred merged 3 commits into
nushell:mainfrom
manavkdubey:investigate/rename-column-17448

Conversation

@manavkdubey

@manavkdubey manavkdubey commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #18108 for #17448.

rename --column could report that a column was missing from the entire input when only a later record lacked it.

[{name: Alice} {age: 30}] | rename -c {name: n}

The error now labels rename with cannot rename column 'name'. The existing highlight on {age: 30} now says row 1 is missing column 'name'. The error code is nu::shell::unsupported_input.

User-facing changes (Release notes)

rename --column now reports the zero-based index of the input row that is missing a requested column.

Additional notes

  • Added regression coverage for a missing column in a later record and in a single record, the highlighted record span, and a successful mapped rename.
  • On macOS, seven rename integration tests and three rename unit tests passed. Formatting, both Clippy checks, Typos, and git diff --check also passed.

@fdncred fdncred left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review overview

🟡 Changes recommended

The new message reads better than "does not exist in the input" for a list literal, and CI is green. One thing to fix before merge: when rows come from from json, open or ls, the error still can't say which row lacks the column, which is the #17448 case. The other two are small: where the record wording is drawn, and the release note.

Findings: 0 High severity · 1 Medium severity · 2 Low severity

Open (3)

Notes from my clanker, checked on cbbc2d6. Built the branch, ran cargo test -p nu-command --test tests -- commands::rename (7 passed), and ran each case on the branch binary and on 0.117.1 (main 651f0e4). CI was green on this head.

Comment thread crates/nu-command/src/filters/rename.rs Resolved
Comment thread crates/nu-command/src/filters/rename.rs Resolved
@manavkdubey

manavkdubey commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review! rename --column now reports the zero-based row index for lists and streams, so the JSON example identifies the third row as row 2 even when all rows share a source span. Single records omit the index. I moved the row detail to the input label and updated the release note. The JSON array and stream regression tests both pass.

@manavkdubey
manavkdubey requested a review from fdncred November 20, 2026 15:28
@fdncred

fdncred commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

I think we're ready to go but this statement in the description isn't quite right, "This now reports Column 'name' is missing from this input record and highlights {age: 30}. The existing error code is preserved.". It would be good to straighten that out and give an example.

@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Nov 20, 2026
@manavkdubey

Copy link
Copy Markdown
Contributor Author

Done @fdncred updated the description

@fdncred
fdncred merged commit f6e23c4 into nushell:main Nov 20, 2026
14 checks passed
@fdncred

fdncred commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants