Skip to content

fix(rpc): normalize legacy un-namespaced method names in dispatcher (OPENHUMAN-TAURI-9Q)#1541

Open
oxoxDev wants to merge 1 commit into
tinyhumansai:mainfrom
oxoxDev:fix-legacy-rpc-normalization-7450370644868266100
Open

fix(rpc): normalize legacy un-namespaced method names in dispatcher (OPENHUMAN-TAURI-9Q)#1541
oxoxDev wants to merge 1 commit into
tinyhumansai:mainfrom
oxoxDev:fix-legacy-rpc-normalization-7450370644868266100

Conversation

@oxoxDev
Copy link
Copy Markdown
Contributor

@oxoxDev oxoxDev commented May 12, 2026

Summary

  • Add Rust-side dispatcher normalization for 16 legacy un-namespaced RPC method names. Sentry issue OPENHUMAN-TAURI-9Q (~19 events).
  • Mirrors the TS-side LEGACY_METHOD_ALIASES table at app/src/services/rpcMethods.ts:23-43 as defense-in-depth.
  • Stale/unbalanced callers (any path that bypasses normalizeRpcMethod) now route to the canonical handler instead of erroring unknown method.

Problem

Production cores log rpc.invoke_method failed: unknown method: openhuman.update_analytics_settingsOPENHUMAN-TAURI-9Q (~19 events). The frontend ships LEGACY_METHOD_ALIASES with normalizeRpcMethod, but at least one call path bypasses normalization and hits the Rust dispatcher raw. Result: legitimate config-domain calls fail with unknown method.

Solution

  • src/core/dispatch.rs — new normalize_legacy_method(method) -> Option<&'static str> mirroring the TS alias table; pre-pass in dispatch() rewrites legacy → canonical and emits a tracing::debug! so we can monitor leftover legacy callers.
  • 16 alias pairs covered, e.g. openhuman.update_analytics_settingsopenhuman.config_update_analytics_settings, openhuman.pingcore.ping.
  • TS-side normalizeRpcMethod left in place — both layers, defense-in-depth.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) — full alias parametric test, unknown/canonical None test, dispatch smoke for openhuman.ping and openhuman.get_analytics_settings
  • Diff coverage ≥ 80% — every alias arm exercised plus dispatch-level integration through dispatch(test_state(), …)
  • Coverage matrix updated — N/A: backend defense-in-depth, no new user-visible feature row
  • All affected feature IDs from the matrix are listed in the PR description under ## RelatedN/A: behaviour-only change
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces — N/A: no release-cut surface touched
  • Linked issue closed via Closes in the ## Related section

Impact

  • Runtime/platform: desktop core (macOS / Windows / Linux) — Rust only. No frontend / Tauri-shell changes.
  • Observability: Sentry event volume drops on OPENHUMAN-TAURI-9Q (~19 events). New debug! log surfaces any caller still on legacy names so we can chase them down.
  • Compatibility: pure addition — canonical method names dispatch identically; legacy names now succeed instead of failing.
  • Security: no new surface; the function is a pure &str → Option<&'static str> mapping.
  • Performance: 16-arm match on &str, allocation-free, single lookup per RPC call.

Related

  • Closes OPENHUMAN-TAURI-9Q
  • Source of truth for alias table: app/src/services/rpcMethods.ts:23-43
  • Follow-up PR(s)/TODOs: monitor the new debug! log over a release cycle to identify which call sites still emit legacy names, then fix them in TS so we can deprecate this Rust-side normalization

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

Linear Issue

  • Key: N/A — Sentry-driven, not Linear
  • URL: N/A

Commit & Branch

  • Branch: fix-legacy-rpc-normalization-7450370644868266100
  • Commit SHA: see git log on PR

Validation Run

  • pnpm --filter openhuman-app format:check — N/A: no app/ changes
  • pnpm typecheck — N/A: no TS changes
  • Focused tests:
    • cargo test --lib core::dispatch::tests::test_normalize_legacy_method_all_aliases
    • cargo test --lib core::dispatch::tests::test_normalize_legacy_method_none_for_unknown_or_canonical
    • cargo test --lib core::dispatch::tests::dispatch_legacy_ping_rewrites_and_succeeds
    • cargo test --lib core::dispatch::tests::dispatch_legacy_alias_routes_to_registry
  • Rust fmt/check (if changed): clean per agent run
  • Tauri fmt/check (if changed): N/A — no app/src-tauri/ changes

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: legacy un-namespaced RPC method names now route to canonical handlers via a dispatcher pre-pass instead of erroring with unknown method.
  • User-visible effect: none direct — bugs that previously surfaced as unknown method Sentry errors now resolve transparently.

Parity Contract

  • Legacy behavior preserved: canonical method names dispatch identically; tests cover both legacy and canonical paths.
  • Guard/fallback/dispatch parity checks: alias table mirrors TS LEGACY_METHOD_ALIASES exactly (16 pairs, verified by parametric test).

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: this PR
  • Resolution: N/A

Authoring note: This PR was prepared by Google Jules (cloud async coding agent) as part of the Wave 1 Sentry triage batch (clusters K / J / H). Branch published to oxoxDev/openhuman and opened cross-repo against tinyhumansai/openhuman.

Summary by CodeRabbit

  • Bug Fixes

    • Legacy RPC method calls are now automatically normalized and routed to their canonical equivalents, ensuring backward compatibility for older client integrations.
  • Tests

    • Added comprehensive test coverage for legacy method normalization and routing.

Review Change Stack

Production cores log 'unknown method' errors for un-namespaced legacy
method names that bypass frontend normalization.

This adds a normalization layer in `src/core/dispatch.rs` that maps
legacy names to their canonical equivalents, mirroring the
`LEGACY_METHOD_ALIASES` table in the frontend.

Specifically:
- `openhuman.update_analytics_settings` -> `openhuman.config_update_analytics_settings`
- And 15 other mappings.

A debug log is emitted when normalization fires for monitoring.
Added unit tests covering all aliases and integration with `dispatch`.

Co-authored-by: oxoxDev <164490987+oxoxDev@users.noreply.github.com>
@oxoxDev oxoxDev requested a review from a team May 12, 2026 11:36
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

This PR adds transparent legacy RPC method-name rewriting to the dispatch function. A new private helper maps old openhuman.* method names to canonical core.* or openhuman.config_* equivalents; the dispatch entry point normalizes incoming method names before logging and routing, and tests validate both the alias mappings and end-to-end behavior.

Changes

Legacy RPC method name normalization in dispatch

Layer / File(s) Summary
Legacy method normalization helper
src/core/dispatch.rs
normalize_legacy_method(method: &str) maps legacy openhuman.* methods (ping, get_*, update_*, and onboarding flags) to their canonical core.* or openhuman.config_* names; unmapped methods return None.
Dispatch integration with normalization and validation
src/core/dispatch.rs
The dispatch entry point calls normalize_legacy_method to rewrite the incoming method name before entry logging and tiered routing. Tests verify alias-to-canonical mappings and confirm dispatch successfully routes rewritten openhuman.ping and openhuman.get_analytics_settings through the existing tier system.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • tinyhumansai/openhuman#1497: Both PRs normalize legacy openhuman.* RPC method names to canonical core.* / openhuman.config_* equivalents (this PR in Rust dispatch helper; retrieved PR in frontend RPC catalog and legacy-alias mappings).
  • tinyhumansai/openhuman#1413: Both PRs implement RPC method-name normalization/legacy-aliasing logic (this PR adds Rust normalize_legacy_method in dispatch.rs; retrieved PR updates JS normalizeRpcMethod).

Poem

🐰 Legacy names, now rewritten,
From openhuman's past—transmuted, smitten!
Dispatch's gentle normalization guide,
Routes old methods with canonical pride.
Hop forward, clean RPC tide! 🌊

🚥 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: normalizing legacy un-namespaced RPC method names in the dispatcher. It is specific, concise, and clearly communicates the primary modification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/core/dispatch.rs (1)

34-38: ⚡ Quick win

Use dispatch-scoped structured fields in the normalization debug log

Please align this log line with the existing dispatcher log format for grepability/correlation ([rpc:dispatch] + key/value fields).

Proposed diff
-        log::debug!(
-            "[rpc] legacy method '{}' rewritten to '{}'",
-            method,
-            canonical
-        );
+        log::debug!(
+            "[rpc:dispatch] normalized_legacy_method legacy_method={} canonical_method={}",
+            method,
+            canonical
+        );

As per coding guidelines, "Use log / tracing at debug / trace level; include stable grep-friendly prefixes ([domain], [rpc]) and correlation 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/core/dispatch.rs` around lines 34 - 38, The debug log call using
log::debug! that currently prints "[rpc] legacy method '{}' rewritten to '{}'"
should be changed to the dispatcher-scoped structured format used elsewhere:
replace the free-form message in the log::debug! invocation (the one referencing
the variables method and canonical) with a grep-friendly prefix "[rpc:dispatch]"
and include stable key/value fields (e.g., method= and canonical=) so the output
becomes "[rpc:dispatch]" plus explicit method=... canonical=... fields for
correlation and consistent grepability; update the log::debug! call that
references method and canonical accordingly.
🤖 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.

Nitpick comments:
In `@src/core/dispatch.rs`:
- Around line 34-38: The debug log call using log::debug! that currently prints
"[rpc] legacy method '{}' rewritten to '{}'" should be changed to the
dispatcher-scoped structured format used elsewhere: replace the free-form
message in the log::debug! invocation (the one referencing the variables method
and canonical) with a grep-friendly prefix "[rpc:dispatch]" and include stable
key/value fields (e.g., method= and canonical=) so the output becomes
"[rpc:dispatch]" plus explicit method=... canonical=... fields for correlation
and consistent grepability; update the log::debug! call that references method
and canonical accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 825bda9b-4951-43d6-98fa-73a2f06c7d66

📥 Commits

Reviewing files that changed from the base of the PR and between 78d1f3d and f0e476a.

📒 Files selected for processing (1)
  • src/core/dispatch.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant