spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Protobuf/Buf Formatter Fails for Files Larger than 64KiB

Open yzhaoa opened this issue 5 months ago • 3 comments

Test case:

  1. Define a .proto files larger than 64 KiB (or your platform's pipe buffer limit). Padding with whitespace should also work.
  2. Configure spotless to format said file.
  3. Run spotlessApply (gradle example).

Expected behavior:

Formatting runs and passes (if valid proto file).

Actual behavior:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':treatment:api:spotlessProtobufApply'.
   ...
Caused by: org.gradle.api.GradleException: There were 1 lint error(s), they must be fixed or suppressed.
src/...:LINE_UNDEFINED buf(java.io.IOException) Broken pipe (...)
Resolve these lints or suppress with `suppressLintsFor`
        at com.diffplug.gradle.spotless.SpotlessApply.performAction(SpotlessApply.java:60)

cat-ing /build/spotless-lints/... shows:

Broken pipe
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:367)
	at java.base/java.io.BufferedOutputStream.implWrite(BufferedOutputStream.java:217)
	at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:206)
	at java.base/java.io.FilterOutputStream.write(FilterOutputStream.java:110)
	at com.diffplug.spotless.ProcessRunner.start(ProcessRunner.java:165)
	at com.diffplug.spotless.ProcessRunner.start(ProcessRunner.java:131)
	at com.diffplug.spotless.ProcessRunner.exec(ProcessRunner.java:114)
	at com.diffplug.spotless.ProcessRunner.exec(ProcessRunner.java:109)
	at com.diffplug.spotless.protobuf.BufStep$State.format(BufStep.java:109)
	at com.diffplug.spotless.FormatterFunc$Closeable$3.apply(FormatterFunc.java:140)
	at com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.format(FormatterStepEqualityOnStateSerialization.java:49)
	at com.diffplug.spotless.LintState.of(LintState.java:177)
	at com.diffplug.spotless.LintState.of(LintState.java:134)
	at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:134)
	at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:117)
...

yzhaoa avatar May 17 '25 00:05 yzhaoa