Repository navigation
fix: gRPC framing correctness and robustness follow-up - #650
Conversation
- Compressed flag now reflects actual payload state (Zstd configured AND compressor initialized), not just configured algorithm. If the compressor is absent the payload is uncompressed and flag must be 0x00. - Pre-allocate grpc_buf at 64 KiB to match encoder_buf/compress_buf pattern and avoid reallocation on first use. - Use u32::try_from for payload length to panic with a clear message instead of silently truncating for pathological >4 GiB payloads. - Add grpc_send_batch_frames_payload test to cover the full encode→frame path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUpdated gRPC framing and buffer handling in Possibly related PRs
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/logfwd-output/src/otlp_sink.rs`:
- Around line 824-865: Rename the test and update its doc comment to accurately
reflect that it validates the combination of OtlpSink::encode_batch and
write_grpc_frame rather than calling OtlpSink::send_batch; specifically update
the function name grpc_send_batch_frames_payload to something like
encode_batch_frames_payload or encode_and_frame_payload, and change the top
comment line to state that the test encodes via encode_batch and then frames
with write_grpc_frame (mention OtlpSink::encode_batch and write_grpc_frame in
the comment) so the test intent and coverage are precise and do not imply
send_batch is exercised.
- Around line 217-220: The code computes payload_is_compressed (based on
self.compression == Compression::Zstd && self.compressor.is_some()) but later
builds request headers using self.compression == Compression::Zstd, which can
falsely advertise compression when compressor is None; update header
construction to use payload_is_compressed (the same boolean passed to
write_grpc_frame) so the HTTP compression header matches the actual payload
compression state and ensure any branch that sets the compression-related header
checks payload_is_compressed (and not just self.compression) as well as avoid
setting compression headers when compressor is None.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 108408e6-381a-4bd8-940e-faafbdb12c4e
📒 Files selected for processing (1)
crates/logfwd-output/src/otlp_sink.rs
- Use payload_is_compressed for Content-Encoding header (matches actual payload state; previously advertised zstd when compressor was None but payload was plain) - Rename grpc_send_batch_frames_payload -> encode_and_frame_payload and update its doc comment to accurately reflect it tests encode_batch + write_grpc_frame, not send_batch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Follow-up to #628 (gRPC framing).
Changes
self.compression == Compression::Zstd, but it should reflect whether the payload is actually compressed. If the compressor wasn't initialized, the payload falls back to uncompressed and the flag must be0x00. Fixed toZstd && compressor.is_some().grpc_buf: Now initialized at 64 KiB to matchencoder_buf/compress_bufand avoid reallocation on first use.u32::try_fromfor payload length: Replaces silentas u32truncation with a clear panic for pathological >4 GiB payloads.grpc_send_batch_frames_payload: Covers the fullencode_batch→write_grpc_framepath, validating the frame header against the actual encoded protobuf bytes.Test plan
cargo test -p logfwd-output— 59 tests pass (includes new test)cargo clippy -p logfwd-output -- -D warnings— cleancargo fmt --check -p logfwd-output— clean🤖 Generated with Claude Code