base32, base64, basenc: drop the "error: " from the invalid-input message - #14396
base32, base64, basenc: drop the "error: " from the invalid-input message#14396Socialpranker wants to merge 1 commit into
Conversation
|
Pushed one more commit: For the record, the one red job here ( |
|
GNU testsuite comparison: |
|
Could you please squash your commits ? Thanks |
| } else if ignore_garbage { | ||
| continue; | ||
| } else { | ||
| return Err(USimpleError::new(1, "error: invalid input")); |
There was a problem hiding this comment.
Localised as base-common-invalid-input in base_common.rs/.ftl, sha a8d7da6.
| if !input.len().is_multiple_of(4) { | ||
| return Err(USimpleError::new( | ||
| 1, | ||
| "error: invalid input (length must be multiple of 4 characters)", |
There was a problem hiding this comment.
should be localised too
There was a problem hiding this comment.
Localised as encoding-error-invalid-input/encoding-error-invalid-input-z85-length in uucore/encoding.rs/.ftl, sha a8d7da6.
…sage The diagnostic already carries the program name, so the extra literal made it read "base64: error: invalid input" where GNU writes "base64: invalid input".
7b7e1f7 to
a8d7da6
Compare
|
Squashed to a single commit, sha a8d7da6. |
Merging this PR will regress 2 benchmarks
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
Flaky CI |
The invalid-input diagnostic carried a literal
error:on top of theprogram name that
uucorealready prints:No other diagnostic in these utilities spells the word "error" — the
neighbouring messages are
basenc: missing encoding type,base64: extra operand, and so on — and none of the GNU ones do either.The fix
Dropping the prefix from the 13 message literals in
src/uucore/src/lib/features/encoding.rsandsrc/uu/base32/src/base_common.rs, and from the seven test assertionsthat pinned the old wording. Nothing else changes: same error kind, same
exit status 1, same trailing detail in the z85 length message.
Not addressed here: GNU also writes the successfully decoded prefix to
stdout before failing, which uutils does not — that is #6008 and is left
alone.
How the GNU behavior was established
By running the installed GNU coreutils 9.11 binaries (Homebrew,
gbase32,gbase64,gbasenc) as a black box on undecodable input across--base64,--base64url,--base32,--base32hex,--base16,--z85and the plain
base32 -d/base64 -dforms, and diffing stderr againstuutils. I did not read GNU coreutils source.
Testing
tests/by-util/test_base32.rs,test_base64.rsandtest_basenc.rsnow pin the GNU wording, so theyare the mutation check: reverting the two source files alone makes all
seven fail.
cargo test --features "base32 base64 basenc" --test tests test_base:119 passed, 0 failed.
cargo clippy -p uu_base32 -p uu_base64 -p uu_basenc --all-targets -- -D warnings:clean.
cargo fmt --check: clean.28 utilities: mismatches 79 -> 74 (base32 1 -> 0, basenc 6 -> 2), no
other bucket moved. The four that remain in these utilities are the
partial-output difference of basenc: emit partial output on invalid input #6008.
Disclosure
Prepared with AI assistance (Claude Opus 5, via Claude Code), per the AI
policy in CONTRIBUTING.md. Every GNU behavior quoted above came from
running the installed binaries, not from reading GPL source. All testing
was run locally.