Repository navigation
Read the plugin request until end of input, not the first short read - #60
Merged
andersfugmann merged 1 commit intoSep 26, 2026
Merged
Conversation
read_all stopped at the first input call that returned fewer than 1024 bytes. Stdlib.input may return fewer bytes than requested before the end of input; only 0 means end of file. On macOS a pipe hands the first read 512 bytes, so the CodeGeneratorRequest was cut and decoding failed with Premature_end_of_input. Read until input returns 0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
anyang-keepers
pushed a commit
to jeong-sik/masc
that referenced
this pull request
Sep 26, 2026
…정본으로 pin 해요 (#39217) * build(opam): pin ocaml-protoc-plugin 6.2.0 with the short-read fix protoc-gen-ocaml 6.2.0 stops reading its request at the first read shorter than its 1024-byte buffer. A macOS pipe hands over 512 bytes first, so every local build of proto/masc_workspace.proto on macOS failed with Premature_end_of_input; CI on Linux never saw it. The pin is 6.2.0 plus the one-commit fix from andersfugmann/ocaml-protoc-plugin#60, pinned as 6.2.0 so the generated code and the lock constraint stay 6.2.0's, and dune-local's pin guard now tells a switch without it to reinstall. live_pin_target also reads the whole pin table: an awk that exited at the match could close the pipe while printf still wrote, and under pipefail that SIGPIPE ended --check with 141 and no report, which dune-local turned into a refused build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(changelog): note the protoc plugin pin Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
Thanks for reporting. The PR looks good. I'll merge once checks have completed. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified, and all assessments support approval.
Review effort: Lite
Findings: None
What changed in this PR
Fixes plugin request truncation by reading stdin until EOF, handling partial pipe reads correctly.
Changes:
- Repeatedly reads input until EOF.
- Reuses buffers while preserving OCaml compatibility.
| File | Description |
|---|---|
src/plugin/protoc_gen_ocaml.ml |
Reads complete protobuf requests from stdin. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
andersfugmann
added a commit
to andersfugmann/opam-repository
that referenced
this pull request
Sep 27, 2026
CHANGES: - Add `package_service_name` to generated service modules, providing the complete protobuf service path directly (andersfugmann/ocaml-protoc-plugin#49, thanks @Nymphium) - Use binary mode for the plugin's standard input and output on Windows (andersfugmann/ocaml-protoc-plugin#51, thanks @linsyking) - Fix JSON decoder initialization when a message references an enum nested in another message (andersfugmann/ocaml-protoc-plugin#59, thanks @mbickers) - Read the complete protoc plugin request instead of treating a short input read as end-of-file (andersfugmann/ocaml-protoc-plugin#60, thanks @jeong-sik)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
read_allinsrc/plugin/protoc_gen_ocaml.mlstops at the firstinputcall that returns fewer than 1024 bytes, and treats that as the end of the request.Stdlib.inputdoes not promise full reads:On macOS a pipe hands the first read 512 bytes. The
CodeGeneratorRequestis then cut at 512 bytes, and the plugin fails:Reproduction
Environment: macOS 26.6.1 (arm64), protoc 34.0 from Homebrew (33.5 fails the same way), OCaml 5.5.1.
main(7cea929),dune runtestfails. There are 10 plugin failures, allPremature_end_of_input. The 6.2.0 release fails the same way.cat request | protoc-gen-ocaml, and a pipe that sends the first 1000 or 2048 bytes and then the rest.read_allrun on that pipe reads 512 of the 16,903 bytes before it stops (OCaml 5.4.0, 5.5.0 and 5.5.1 alike).Fix
Read until
inputreturns 0. The loop uses onlyinputandBuffer, so it keeps theocaml >= 4.08.0bound (In_channel.input_allneeds 4.14).Testing
With this change, on the same machine:
dune runtestpasses.protoc34.0 generates code through the rebuilt plugin. Its output differs from the 6.2.0 output only bypackage_service_name, which is already onmain.🤖 Generated with Claude Code