Skip to content

fix(commands): return error on invalid alignment in fill command - #19361

Merged
fdncred merged 2 commits into
nushell:mainfrom
patatoish:fix/fill-invalid-alignment
Oct 28, 2026
Merged

fdncred merged 2 commits into
nushell:mainfrom
patatoish:fix/fill-invalid-alignment

Conversation

@patatoish

@patatoish patatoish commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Previously, fill silently accepted unknown values for the --alignment (-a) option and defaulted to Left. An explicit // TODO: This should probably be an error comment was present in the FromValue implementation for FillAlignment.

This PR changes FillAlignment::from_value to return ShellError::InvalidValue when an invalid alignment string is supplied, informing the user about the expected valid choices (left, right, center/middle, centerright/middleright).

User-facing changes (Release notes)

fill --alignment now errors on an unknown alignment instead of silently left-aligning; valid values are left, right, center/middle and centerright/middleright.

Tests + Formatting

  • Added integration tests in crates/nu-command/tests/commands/fill.rs verifying both valid alignments and the error raised on invalid/empty input.
  • Ran cargo test -p nu-command --test tests -- commands::fill (4 passed).
  • Verified formatting with cargo fmt --all -- --check.

@fdncred

fdncred commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

looks like your backslashes \ need to be replace with backticks `

@patatoish

Copy link
Copy Markdown
Contributor Author

looks like your backslashes \ need to be replace with backticks `

im fixing it rn thank you

@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 error itself works as described. The notes are about where the new tests live, what they check, and keeping the help text and completions in line with the new message.

Findings: 0 High severity · 0 Medium severity · 5 Low severity

Open (5)

Notes from my clanker, checked on 038c956. Built the branch and ran fill -a with invalid, '', centre, LEFT, MiddleRight, a variable and a list input; cargo fmt --all -- --check and cargo test -p nu-command --test tests -- fill pass.

@fdncred

fdncred commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

when you're finished, please respond on each review comment to make sure we didn't miss anything

@patatoish
patatoish requested a review from fdncred October 28, 2026 13:59

@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

All 5 threads from the first review are fixed on 80c13a7, and I've resolved them. One new Low: the PR body still describes the first commit.

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

Open (1)

Notes from my clanker, checked on 80c13a7. Built the branch and ran cargo test -p nu-command --test tests -- commands::fill (4 passed), the fill test_examples (1 passed), cargo fmt --all --check and typos, and ran each alignment name and invalid value on the branch binary and on main at 7a49c10. I didn't run clippy locally; CI's clippy step passed on this head.

@patatoish

Copy link
Copy Markdown
Contributor Author

The PR description has been updated with the corrected error output ('invalid'), the breaking change note regarding fallback behavior (fill -a centre), and the updated test command/path.

@patatoish
patatoish requested a review from fdncred October 28, 2026 17:58
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Oct 28, 2026
@fdncred
fdncred merged commit 56bdf6e into nushell:main Oct 28, 2026
11 checks passed
@fdncred

fdncred commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.117.0 milestone Oct 28, 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