From 152dbb23f733be9bd319efc8d77d005a372e6466 Mon Sep 17 00:00:00 2001 From: sanil-23 Date: Thu, 28 May 2026 20:22:44 +0200 Subject: [PATCH 1/3] fix(legacy_aliases): tolerate unquoted keys + skip comments in alias-table parser PR #2853 added `health_snapshot: CORE_RPC_METHODS.healthSnapshot,` to LEGACY_METHOD_ALIASES in app/src/services/rpcMethods.ts. Prettier strips quotes from keys that are valid JS identifiers, so the canonical TS form is unquoted (`health_snapshot:`, not `'health_snapshot':`). But the `frontend_legacy_aliases_match_server_alias_table` test's parser required every key to be quoted via `quoted_value()`, which panicked: expected quoted value in `health_snapshot` This blocked CI on every PR rebasing onto current main (#2687 + #2715 confirmed inheriting the failure). Fix the parser, not the source file: 1. Filter `//`-comment lines from the LEGACY_METHOD_ALIASES body before compacting (otherwise the first quoted key picks up the inline comment header). 2. Accept both quoted (`'foo':`) and bare-identifier (`foo:`) keys. Co-Authored-By: Claude --- src/core/legacy_aliases.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/legacy_aliases.rs b/src/core/legacy_aliases.rs index c3196bf4e1..285f576738 100644 --- a/src/core/legacy_aliases.rs +++ b/src/core/legacy_aliases.rs @@ -223,7 +223,7 @@ mod tests { let compact = body .lines() .map(str::trim) - .filter(|line| !line.is_empty()) + .filter(|line| !line.is_empty() && !line.starts_with("//")) .collect::>() .join(" "); let mut aliases = BTreeMap::new(); @@ -235,7 +235,14 @@ mod tests { let (legacy, target_expr) = entry .split_once(':') .unwrap_or_else(|| panic!("expected legacy alias entry, got `{entry}`")); - let legacy = quoted_value(legacy); + // Prettier strips quotes from keys that are valid JS identifiers + // (e.g. `health_snapshot`), so accept both `'foo':` and bare `foo:`. + let legacy_trimmed = legacy.trim(); + let legacy = if legacy_trimmed.starts_with('\'') || legacy_trimmed.starts_with('"') { + quoted_value(legacy) + } else { + legacy_trimmed.to_string() + }; let target_expr = target_expr.trim(); let canonical = if let Some(key) = target_expr.strip_prefix("CORE_RPC_METHODS.") { core_methods From 857c389ab086396decbbf2735a41f008bea3bb5c Mon Sep 17 00:00:00 2001 From: sanil-23 Date: Thu, 28 May 2026 20:45:00 +0200 Subject: [PATCH 2/3] test(legacy_aliases): cover bare-identifier keys + comment skipping in parser Add parse_frontend_legacy_aliases_accepts_bare_identifier_keys_and_skips_comments test per CodeRabbit feedback on #2865: exercises the new parser tolerance introduced in the previous commit (bare identifier keys like `health_snapshot:` that Prettier produces, plus // comment lines in the alias body). Co-Authored-By: Claude --- src/core/legacy_aliases.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/core/legacy_aliases.rs b/src/core/legacy_aliases.rs index 285f576738..d0f68fe97d 100644 --- a/src/core/legacy_aliases.rs +++ b/src/core/legacy_aliases.rs @@ -352,6 +352,32 @@ mod tests { ); } + #[test] + fn parse_frontend_legacy_aliases_accepts_bare_identifier_keys_and_skips_comments() { + // Prettier strips redundant quotes from keys that are valid JS + // identifiers, so the canonical form for a simple key like + // `health_snapshot` is unquoted. The parser must accept both + // `'foo':` and bare `foo:`, and must ignore `//` comment lines + // in the LEGACY_METHOD_ALIASES body. + let source = "export const CORE_RPC_METHODS = {\n alphaMethod: 'openhuman.alpha',\n betaMethod: 'openhuman.beta',\n} as const;\n\nexport const LEGACY_METHOD_ALIASES: Record = {\n // legacy aliases for the alpha method\n 'openhuman.legacy_alpha': CORE_RPC_METHODS.alphaMethod,\n beta_legacy: CORE_RPC_METHODS.betaMethod,\n};\n"; + let core_methods = parse_core_rpc_methods(source); + let aliases = parse_frontend_legacy_aliases(source, &core_methods); + assert_eq!( + aliases.get("openhuman.legacy_alpha").map(String::as_str), + Some("openhuman.alpha"), + "quoted-key entry should still resolve" + ); + assert_eq!( + aliases.get("beta_legacy").map(String::as_str), + Some("openhuman.beta"), + "bare-identifier key should resolve (Prettier-normalized form)" + ); + assert!( + !aliases.keys().any(|k| k.contains("//") || k.contains("legacy aliases")), + "comment text must not be captured as a key" + ); + } + #[test] #[should_panic(expected = "legacy alias references unknown CORE_RPC_METHODS")] fn parse_frontend_legacy_aliases_panics_on_unknown_core_method_ref() { From 2238e71cdb04d3130fafb9536aeba2479585f9d7 Mon Sep 17 00:00:00 2001 From: sanil-23 Date: Thu, 28 May 2026 20:51:04 +0200 Subject: [PATCH 3/3] style: cargo fmt --all --- src/core/legacy_aliases.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/legacy_aliases.rs b/src/core/legacy_aliases.rs index d0f68fe97d..fcc605b59b 100644 --- a/src/core/legacy_aliases.rs +++ b/src/core/legacy_aliases.rs @@ -373,7 +373,9 @@ mod tests { "bare-identifier key should resolve (Prettier-normalized form)" ); assert!( - !aliases.keys().any(|k| k.contains("//") || k.contains("legacy aliases")), + !aliases + .keys() + .any(|k| k.contains("//") || k.contains("legacy aliases")), "comment text must not be captured as a key" ); }