-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(rpc): rewrite legacy method names server-side before dispatch (OPENHUMAN-TAURI-BQ) #1544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
senamakel
merged 3 commits into
tinyhumansai:main
from
sanil-23:fix/composio-update-trigger-settings-rpc
May 13, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| //! Server-side legacy RPC method aliases. | ||
| //! | ||
| //! Mirrors the frontend's `LEGACY_METHOD_ALIASES` table in | ||
| //! `app/src/services/rpcMethods.ts`. The frontend rewrites outgoing method | ||
| //! names for clients that just updated; this module rewrites incoming | ||
| //! method names for clients that haven't updated yet (older shipped bundles | ||
| //! in the wild). Together they form a symmetric migration safety net: | ||
| //! either side can be the one that's behind, and the call still resolves. | ||
| //! | ||
| //! When adding or removing an entry here, keep | ||
| //! `app/src/services/rpcMethods.ts:LEGACY_METHOD_ALIASES` in sync. The two | ||
| //! tables are intentionally identical: the same legacy → canonical map | ||
| //! applied at both ends of the wire. | ||
| //! | ||
| //! The rewrite is a pure key-to-key lookup. No domain branches, no | ||
| //! parameter inspection — if a method isn't in the table, it passes through | ||
| //! untouched. | ||
|
|
||
| /// Legacy → canonical RPC method name pairs. | ||
| /// | ||
| /// Order doesn't matter for correctness, but is kept alphabetical by legacy | ||
| /// key for easier diffing against the frontend table. | ||
| const LEGACY_ALIASES: &[(&str, &str)] = &[ | ||
| ( | ||
| "openhuman.get_analytics_settings", | ||
| "openhuman.config_get_analytics_settings", | ||
| ), | ||
| ( | ||
| "openhuman.get_composio_trigger_settings", | ||
| "openhuman.config_get_composio_trigger_settings", | ||
| ), | ||
| ("openhuman.get_config", "openhuman.config_get"), | ||
| ( | ||
| "openhuman.get_runtime_flags", | ||
| "openhuman.config_get_runtime_flags", | ||
| ), | ||
| ("openhuman.ping", "core.ping"), | ||
| ( | ||
| "openhuman.set_browser_allow_all", | ||
| "openhuman.config_set_browser_allow_all", | ||
| ), | ||
| ( | ||
| "openhuman.update_analytics_settings", | ||
| "openhuman.config_update_analytics_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_browser_settings", | ||
| "openhuman.config_update_browser_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_composio_trigger_settings", | ||
| "openhuman.config_update_composio_trigger_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_local_ai_settings", | ||
| "openhuman.config_update_local_ai_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_memory_settings", | ||
| "openhuman.config_update_memory_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_model_settings", | ||
| "openhuman.config_update_model_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_runtime_settings", | ||
| "openhuman.config_update_runtime_settings", | ||
| ), | ||
| ( | ||
| "openhuman.update_screen_intelligence_settings", | ||
| "openhuman.config_update_screen_intelligence_settings", | ||
| ), | ||
| ( | ||
| "openhuman.workspace_onboarding_flag_exists", | ||
| "openhuman.config_workspace_onboarding_flag_exists", | ||
| ), | ||
| ( | ||
| "openhuman.workspace_onboarding_flag_set", | ||
| "openhuman.config_workspace_onboarding_flag_set", | ||
| ), | ||
| ]; | ||
|
|
||
| /// Resolves a legacy RPC method name to its canonical form, if any. | ||
| /// | ||
| /// Returns the canonical name when `method` is a known legacy alias; | ||
| /// otherwise returns `method` unchanged. This function is idempotent: | ||
| /// calling it on an already-canonical name (or any unrelated name) is a | ||
| /// no-op. | ||
| /// | ||
| /// Returns a borrow that lives for at least the input's lifetime — the | ||
| /// matched-canonical branch returns `&'static`, the pass-through branch | ||
| /// returns the input borrow; elision picks the tighter input lifetime. | ||
| pub fn resolve_legacy(method: &str) -> &str { | ||
| for (legacy, canonical) in LEGACY_ALIASES { | ||
| if *legacy == method { | ||
| return canonical; | ||
| } | ||
| } | ||
| method | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn resolve_legacy_rewrites_every_table_entry() { | ||
| for (legacy, canonical) in LEGACY_ALIASES { | ||
| assert_eq!( | ||
| resolve_legacy(legacy), | ||
| *canonical, | ||
| "expected legacy alias {legacy} to resolve to {canonical}", | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn resolve_legacy_rewrites_composio_trigger_settings() { | ||
| // The specific case observed in Sentry: older bundles called the | ||
| // bare `openhuman.update_composio_trigger_settings` against a core | ||
| // that only registers the namespaced form. | ||
| assert_eq!( | ||
| resolve_legacy("openhuman.update_composio_trigger_settings"), | ||
| "openhuman.config_update_composio_trigger_settings", | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn resolve_legacy_passes_through_unknown_methods() { | ||
| assert_eq!( | ||
| resolve_legacy("openhuman.memory_list_namespaces"), | ||
| "openhuman.memory_list_namespaces" | ||
| ); | ||
| assert_eq!(resolve_legacy("does.not.exist"), "does.not.exist"); | ||
| assert_eq!(resolve_legacy(""), ""); | ||
| } | ||
|
|
||
| #[test] | ||
| fn resolve_legacy_is_idempotent_for_canonical_names() { | ||
| // Canonical names already match what the registry expects; | ||
| // running them through the resolver must be a no-op so callers | ||
| // can wrap the lookup unconditionally. | ||
| for (_, canonical) in LEGACY_ALIASES { | ||
| assert_eq!( | ||
| resolve_legacy(canonical), | ||
| *canonical, | ||
| "canonical {canonical} must pass through unchanged", | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn resolve_legacy_returned_str_equals_table_value() { | ||
| // Sanity check: the function returns the canonical str slice from | ||
| // the table when it matches, not a copy of the input. | ||
| let out = resolve_legacy("openhuman.ping"); | ||
| assert_eq!(out, "core.ping"); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] The lifetime annotation
pub fn resolve_legacy<'a>(method: &'a str) -> &'a stris technically incorrect when returning a&'static strfrom the table — the returned reference lives longer than'a. It compiles because'static: 'a, but the signature under-promises. Consider lifetime elision (pub fn resolve_legacy(method: &str) -> &str) which already does the right thing, or explicitly return&'static strwhen matched. Not a bug, just slightly misleading.