Skip to content

fmt: propagate read errors instead of silently treating them as EOF - #12430

Merged
RenjiSann merged 1 commit into
uutils:mainfrom
gabrielhnf:fix-fmt-error-propagation
Nov 19, 2026
Merged

RenjiSann merged 1 commit into
uutils:mainfrom
gabrielhnf:fix-fmt-error-propagation

Conversation

@gabrielhnf

@gabrielhnf gabrielhnf commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10581

FileLines iterator was silently swallowing IO errors by returning None on any read failure, making them indistinguishable from end-of-file. This caused fmt to exit successfully with code 0 when reading files that produce IO errors, such as /proc/self/mem.

Changes:

  • FileLines::Item is now Result<Line, std::io::Error>, propagating read errors to callers
  • Added ParagraphStreamError enum to distinguish between unformatted passthrough lines and IO errors
  • ParagraphStream::Item is now Result<Paragraph, ParagraphStreamError>
  • process_file now returns an error on ParagraphStreamError::IoError instead of iterating over an empty stream
  • Added a regression test that verifies $ fmt /proc/self/mem fails with exit code 1.

@github-actions

github-actions Bot commented May 21, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)

@gabrielhnf
gabrielhnf force-pushed the fix-fmt-error-propagation branch from 3101fed to db48aa6 Compare May 21, 2026 22:21
Comment thread src/uu/fmt/src/parasplit.rs Resolved
@gabrielhnf
gabrielhnf force-pushed the fix-fmt-error-propagation branch 2 times, most recently from 1900c70 to 19512c1 Compare October 23, 2026 18:19
@gabrielhnf
gabrielhnf requested a review from RenjiSann November 11, 2026 20:01
Comment thread src/uu/fmt/src/parasplit.rs Resolved
@sylvestre
sylvestre force-pushed the fix-fmt-error-propagation branch from 19512c1 to c40cdc7 Compare November 14, 2026 03:28
@gabrielhnf
gabrielhnf force-pushed the fix-fmt-error-propagation branch 4 times, most recently from 2f10067 to 9c29cde Compare November 15, 2026 13:11
Comment thread src/uu/fmt/src/fmt.rs Resolved
@gabrielhnf
gabrielhnf force-pushed the fix-fmt-error-propagation branch from 9c29cde to 067a6c3 Compare November 16, 2026 01:10
@sylvestre
sylvestre force-pushed the fix-fmt-error-propagation branch from 067a6c3 to 7c09843 Compare November 16, 2026 14:42
@RenjiSann
RenjiSann force-pushed the fix-fmt-error-propagation branch from 7c09843 to 3c9121c Compare November 18, 2026 16:05
@RenjiSann
RenjiSann enabled auto-merge (rebase) November 18, 2026 16:06
@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+108 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@RenjiSann
RenjiSann merged commit 2f07bfd into uutils:main Nov 19, 2026
113 of 114 checks passed
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.

fmt /proc/self/mem silently success

3 participants