Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/src/services/__tests__/rpcMethods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ describe('rpcMethods catalog', () => {
path.resolve(__dirname, '../../../../src/openhuman/embeddings/schemas.rs'),
'utf8'
),
fs.readFileSync(
path.resolve(__dirname, '../../../../src/openhuman/health/schemas.rs'),
'utf8'
),
].join('\n');

for (const method of Object.values(CORE_RPC_METHODS)) {
Expand All @@ -89,7 +93,9 @@ describe('rpcMethods catalog', () => {
? 'embeddings'
: methodRoot.startsWith('providers_')
? 'providers'
: 'config';
: methodRoot.startsWith('health_')
? 'health'
: 'config';
const fnName = methodRoot.slice(`${namespace}_`.length);
expect(schemaSources).toContain(`namespace: "${namespace}"`);
expect(schemaSources).toContain(`function: "${fnName}"`);
Expand Down
2 changes: 2 additions & 0 deletions app/src/services/rpcMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const CORE_RPC_METHODS = {
embeddingsClearApiKey: 'openhuman.embeddings_clear_api_key',
embeddingsEmbed: 'openhuman.embeddings_embed',
embeddingsTestConnection: 'openhuman.embeddings_test_connection',
healthSnapshot: 'openhuman.health_snapshot',
} as const;

export type CoreRpcMethod = (typeof CORE_RPC_METHODS)[keyof typeof CORE_RPC_METHODS];
Expand Down Expand Up @@ -66,6 +67,7 @@ export const LEGACY_METHOD_ALIASES: Record<string, CoreRpcMethod> = {
'openhuman.local_ai_presets': CORE_RPC_METHODS.inferencePresets,
'openhuman.providers_list_models': CORE_RPC_METHODS.inferenceListModels,
'openhuman.inference_embed': CORE_RPC_METHODS.embeddingsEmbed,
health_snapshot: CORE_RPC_METHODS.healthSnapshot,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Blocker — this inline comment breaks the Rust drift-guard parser frontend_legacy_aliases_match_server_alias_table in src/core/legacy_aliases.rs::parse_frontend_legacy_aliases (it doesn't filter // lines before .join(" ").split(',')). CI panics at src/core/legacy_aliases.rs:174:

expected quoted value in `// bare form used by older clients before the `openhuman.` prefix was established health_snapshot`

Drop the comment (or lift it to a doc comment ABOVE the export const LEGACY_METHOD_ALIASES declaration):

Suggested change
health_snapshot: CORE_RPC_METHODS.healthSnapshot,
health_snapshot: CORE_RPC_METHODS.healthSnapshot,

};

export function normalizeRpcMethod(method: string): string {
Expand Down
15 changes: 15 additions & 0 deletions src/core/legacy_aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ const LEGACY_ALIASES: &[(&str, &str)] = &[
"openhuman.local_ai_diagnostics",
"openhuman.inference_diagnostics",
),
// bare `health_snapshot` (no namespace prefix) was used by older clients
// before the canonical `openhuman.health_snapshot` form was established.
("health_snapshot", "openhuman.health_snapshot"),
("openhuman.inference_embed", "openhuman.embeddings_embed"),
("openhuman.local_ai_presets", "openhuman.inference_presets"),
(
Expand Down Expand Up @@ -352,6 +355,18 @@ mod tests {
);
}

#[test]
fn resolve_legacy_rewrites_bare_health_snapshot() {
// Sentry CORE-RUST-FG: older clients (and some SDK callers) issued
// `health_snapshot` without the `openhuman.` namespace prefix. The
// alias table must rewrite it to the canonical form so the call
// resolves against the registered controller.
assert_eq!(
resolve_legacy("health_snapshot"),
"openhuman.health_snapshot",
);
}

#[test]
fn resolve_legacy_passes_through_unknown_methods() {
assert_eq!(
Expand Down
Loading