openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

fix(rpc): suppress Sentry noise for JSON-RPC probes

Open YonganZhang opened this issue 5 months ago • 2 comments

Summary

  • Suppresses Sentry reporting for common JSON-RPC discovery/status/auth probe methods when they miss the OpenHuman RPC table.
  • Keeps the wire behavior unchanged: probe callers still receive the normal JSON-RPC unknown method response.
  • Adds regression coverage that known probe misses skip Sentry while unrelated unknown methods are still reported.

Problem

  • Generic clients and tooling can probe JSON-RPC servers with method names like rpc.discover, list_methods, status, auth.status, and config/get.
  • OpenHuman does not implement those methods, so returning unknown method is correct.
  • Reporting those expected probe misses to Sentry creates noise and obscures actionable unknown-method errors.

Solution

  • Added a small classifier for exact probe-method unknown method: <method> failures at the JSON-RPC transport boundary.
  • Logs those probe misses at info level and skips Sentry reporting.
  • Anchors the classifier on both method name and exact unknown-method message so real handler errors for similarly named methods still report normally.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • [x] Diff coverage >= 80% - changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by .github/workflows/pr-ci.yml. Focused Rust tests were added; local execution is blocked by missing system pkg-config deps listed below.
  • [x] Coverage matrix updated - N/A: behavior-only transport noise-classification change; no feature row added/removed/renamed.
  • [x] All affected feature IDs from the matrix are listed in the PR description under ## Related - N/A: no feature ID applies to this transport noise-classification fix.
  • [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
  • [x] Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) - N/A: no release-cut smoke surface changed.
  • [x] Linked issue closed via Closes #NNN in the ## Related section

Impact

  • Runtime impact is limited to Sentry/error-reporting classification for exact generic JSON-RPC probe misses.
  • No API response shape changes, no migration, no network dependency, and no frontend behavior change.
  • Genuine unknown methods and non-probe errors continue through the existing Sentry reporting path.

Related

  • Closes #3567
  • Follow-up PR(s)/TODOs: none

AI Authored PR Metadata (required for Codex/Linear PRs)

Keep this section for AI-authored PRs. For human-only PRs, mark each field N/A.

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/3567-rpc-probe-noise
  • Commit SHA: 6c38e96d

Validation Run

  • [x] pnpm --filter openhuman-app format:check - N/A: Rust-only change
  • [x] pnpm typecheck - N/A: Rust-only change
  • [x] Focused tests: attempted cargo test is_jsonrpc_probe_unknown_method_matches_only_generic_probe_misses --lib and cargo test thread_not_found_rpc_error_does_not_report_to_sentry --lib
  • [x] Rust fmt/check (if changed): cargo fmt --check
  • [x] Tauri fmt/check (if changed): N/A: no Tauri config/plugin change

Validation Blocked

  • command: env CC=/usr/bin/gcc CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/gcc cargo test is_jsonrpc_probe_unknown_method_matches_only_generic_probe_misses --lib
  • error: local system pkg-config deps are missing: alsa.pc and xi.pc
  • impact: the focused tests did not execute locally; formatting and diff whitespace checks passed, and CI should run in an environment with the required system packages.

Behavior Changes

  • Intended behavior change: exact generic JSON-RPC probe unknown-method misses no longer report to Sentry.
  • User-visible effect: none; callers still receive the same JSON-RPC unknown-method error.

Parity Contract

  • Legacy behavior preserved: JSON-RPC response body and status remain unchanged.
  • Guard/fallback/dispatch parity checks: regression test keeps unrelated unknown methods on the Sentry path.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none found
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved JSON-RPC error handling for expected discovery/auth/status probe requests, preventing routine “unknown method” cases from triggering false alerts.
    • Updated logging and reporting logic so probe-related failures are treated as non-actionable while real issues still surface normally.
  • Tests
    • Added regression coverage to ensure probe “unknown method” detection only applies to the intended method set and exact error text, with no alerting emitted for these cases.

YonganZhang avatar Jun 13 '26 22:06 YonganZhang

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 526e8049-aece-433c-b947-2fb29e299220

📥 Commits

Reviewing files that changed from the base of the PR and between 6c38e96dca5278ce08b3cda610785c7d7265de21 and d8181847223a20b0777538742d30963052da5999.

📒 Files selected for processing (2)
  • src/core/jsonrpc.rs
  • src/core/jsonrpc_tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/core/jsonrpc.rs
  • src/core/jsonrpc_tests.rs

📝 Walkthrough

Walkthrough

JSON-RPC probe method calls (rpc.discover, list_methods, status, auth.status, config/get) are detected in error handling and filtered from Sentry reporting. A new predicate identifies these methods when they produce "unknown method" errors, the error handler logs them at info level instead, and tests verify both the detection logic and that no Sentry events are created for these probe requests.

Changes

JSON-RPC Probe Method Error Filtering

Layer / File(s) Summary
Probe detection helper
src/core/jsonrpc.rs
New private predicate is_jsonrpc_probe_unknown_method(method, msg) matches a fixed allowlist of method names against an exact error message format "unknown method: {method}".
Error handler probe filtering
src/core/jsonrpc.rs
Error handling pipeline adds an else if branch that uses the probe detection helper to recognize probe unknown-method failures, logs an info message, and skips Sentry reporting.
Test coverage
src/core/jsonrpc_tests.rs
Import of probe detection helper; new regression test verifies the probe detection logic for both matching cases (exact allowlist and error format) and non-matching cases (unrelated methods and mismatched messages); existing Sentry test is updated to confirm no events are emitted for probe method requests.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 Probe requests no more make Sentry go boom,
Known methods logged with gentle zoom,
Filters in place with tests so bright,
Error noise fades into the night. 🌙✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: suppressing Sentry noise for JSON-RPC probe method errors.
Linked Issues check ✅ Passed The changes implement the core requirement from #3567 by adding a classifier to prevent JSON-RPC probe methods from generating Sentry errors while preserving the reporting path for genuinely unexpected methods.
Out of Scope Changes check ✅ Passed All changes focus on the narrow scope of JSON-RPC error classification for probe methods, with no unrelated modifications to API responses, migrations, or network behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jun 13 '26 22:06 coderabbitai[bot]

Updated in d8181847: imported is_jsonrpc_probe_unknown_method into the test module and adjusted the helper to avoid formatting allocation on the error path.\n\nValidation: cargo fmt --check passed; git diff --check passed. Local cargo test is still blocked by the machine linker rejecting -m64 while compiling dependency build scripts, so CI should be the authoritative Rust test signal.

YonganZhang avatar Jun 14 '26 17:06 YonganZhang