Repository navigation
Conversation
…inyhumansai#1814) Bind payload JSON once and slice via floor_char_boundary so multi-byte characters straddling byte 500 no longer abort the core thread (OPENHUMAN-TAURI-KC). Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a unit test that supplies a JSON payload with a multi-byte UTF-8 character straddling byte 500 and verifies handle_sio_event processes it without panicking or changing ConnectionStatus. ChangesUTF-8 Truncation Test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openhuman/socket/event_handlers.rs (1)
30-40:⚠️ Potential issue | 🟠 Major | ⚡ Quick winStop logging raw payload previews and serialize once.
On Line 33 and Line 35,
data.to_string()is still executed twice. Also, Line 40 logs raw payload content, which can expose sensitive fields.Suggested patch
- log::info!( - "[socket] event received: name={} data_bytes={}", - event_name, - data.to_string().len() - ); - let payload_json = data.to_string(); + let payload_json = data.to_string(); + log::info!( + "[socket] event received: name={} data_bytes={}", + event_name, + payload_json.len() + ); let preview_end = crate::openhuman::util::floor_char_boundary(&payload_json, 500); log::debug!( - "[socket] event payload: name={} data={}", + "[socket] event payload preview: name={} preview_bytes={} total_bytes={}", event_name, - &payload_json[..preview_end] + preview_end, + payload_json.len() );As per coding guidelines: “Never log secrets, raw JWTs, API keys, credentials, or full PII in debug logs; redact or omit sensitive fields.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openhuman/socket/event_handlers.rs` around lines 30 - 40, The code currently calls data.to_string() twice and logs a raw payload preview which may expose sensitive fields; fix by converting data to a single String once into payload_json (use the existing payload_json variable), compute preview_end via crate::openhuman::util::floor_char_boundary(&payload_json, 500), log only the payload length with log::info (using event_name and payload_json.len()) and replace the raw debug payload log (log::debug in this block) with a redacted or safe preview derived from payload_json (e.g., redact known sensitive keys or show a fixed placeholder or sanitized substring using floor_char_boundary) so no raw JWTs/API keys/PII are emitted; ensure you reference event_name, data, payload_json, floor_char_boundary, log::info and log::debug when making changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/openhuman/socket/event_handlers.rs`:
- Around line 30-40: The code currently calls data.to_string() twice and logs a
raw payload preview which may expose sensitive fields; fix by converting data to
a single String once into payload_json (use the existing payload_json variable),
compute preview_end via
crate::openhuman::util::floor_char_boundary(&payload_json, 500), log only the
payload length with log::info (using event_name and payload_json.len()) and
replace the raw debug payload log (log::debug in this block) with a redacted or
safe preview derived from payload_json (e.g., redact known sensitive keys or
show a fixed placeholder or sanitized substring using floor_char_boundary) so no
raw JWTs/API keys/PII are emitted; ensure you reference event_name, data,
payload_json, floor_char_boundary, log::info and log::debug when making changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a9392c0-aa88-4fe7-acbc-fcfb893f09fa
📒 Files selected for processing (1)
src/openhuman/socket/event_handlers.rs
# Conflicts: # src/openhuman/socket/event_handlers.rs
|
Merged Net code-change diff vs main is now empty for the affected file; the PR effectively contributes one extra regression test. Maintainers may want to close this PR as superseded by #1818 (per the duplicate note already in the PR body). Tests run locally: Pre-push hook bypassed with |
…#1814) (tinyhumansai#1826) Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
Summary
handle_sio_eventwhen Socket.IO payload JSON contains a multi-byte UTF-8 codepoint straddling byte 500 (OPENHUMAN-TAURI-KC).data.to_string()once and slice viacrate::openhuman::util::floor_char_boundary(same helper as fix(memory_tree, e2e tests ): deterministic query_topic ordering + robust CEF cleanup #1751 memory-tree body preview).handle_sio_event_debug_truncation_respects_utf8_boundarywith a Cyrillic fixture at byte 500.Problem
handle_sio_eventlogged incoming payloads with a naked byte slice:When the JSON serialization is ≥500 bytes and a multi-byte character (e.g. Cyrillic
'н') straddles byte 500, the core thread panicked (byte index 500 is not a char boundary). Real Sentry repro: WhatsApp ingest payload on Windows (OPENHUMAN-TAURI-KC).Solution
let payload_json = data.to_string();let preview_end = floor_char_boundary(&payload_json, 500);&payload_json[..preview_end]— never slices inside a codepoint.Submission Checklist
handle_sio_event_*tests (local:cargo test --lib openhuman::socket::event_handlers::tests)## Related— N/A: no matrix feature IDs changeddocs/RELEASE-MANUAL-SMOKE.md) — N/A: log truncation onlyCloses #NNNin the## RelatedsectionImpact
data.to_string()per event on the debug path.Related
policy.rscommand log truncation)floor_char_boundaryin memory-tree ingest)fix/1814-socket-char-boundary-panic) addresses the same issue by removing raw payload from debug logs entirely. This PR follows the issue’s statedfloor_char_boundaryapproach; maintainers should pick one canonical fix before merge.AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
cursor/a01-1814-socket-log-utf8-boundary7ce2d5c8eed06a502a622a5a791a6d2d743121c4Validation Run
pnpm --filter openhuman-app format:checkpnpm typecheckCARGO_TARGET_DIR=target cargo test --lib openhuman::socket::event_handlers::tests(18 passed including new regression)cargo fmt --manifest-path Cargo.toml --all --checkValidation Blocked
command:pnpm test:coverage/pnpm test:rust(full diff-cover gate)error:Not run locally in this session (pre-push hook ran format, lint, typecheck,rust:checksuccessfully)impact:CI coverage gate on PR should be authoritative; changed surface is small and fully unit-testedBehavior Changes
handle_sio_eventno longer panics on multi-byte UTF-8 at the 500-byte log preview boundary.Parity Contract
match event_namedispatch unchanged.Duplicate / Superseded PR Handling
Made with Cursor
Summary by CodeRabbit