fix(legacy_aliases): tolerate unquoted keys + skip comments in alias-table parser#2865
Conversation
|
Warning Review limit reached
More reviews will be available in 42 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Rust test helper in ChangesLegacy Alias Parser Robustness
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Actionable comments posted: 0 |
…table parser PR tinyhumansai#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 (tinyhumansai#2687 + tinyhumansai#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 <noreply@anthropic.com>
c2f8433 to
152dbb2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/core/legacy_aliases.rs`:
- Around line 238-245: Add a unit test to cover bare identifier keys for the new
parsing logic: create a test (e.g.,
parse_frontend_legacy_aliases_accepts_bare_identifier_keys) that builds a source
string containing CORE_RPC_METHODS and LEGACY_METHOD_ALIASES with both a bare
key (health_snapshot: CORE_RPC_METHODS.healthSnapshot) and a quoted key, call
parse_core_rpc_methods and parse_frontend_legacy_aliases, and assert that
aliases.get("health_snapshot") maps to "openhuman.health_snapshot" and the
quoted key still resolves; this ensures the legacy_trimmed/quoted_value branch
handling of bare identifiers is exercised alongside the existing
parse_frontend_legacy_aliases_resolves_core_method_refs_and_literals test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d643bae3-b633-47b8-ba13-a50ab024af9e
📒 Files selected for processing (1)
src/core/legacy_aliases.rs
…n parser Add parse_frontend_legacy_aliases_accepts_bare_identifier_keys_and_skips_comments test per CodeRabbit feedback on tinyhumansai#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 <noreply@anthropic.com>
|
Actionable comments posted: 0 |
graycyrus
left a comment
There was a problem hiding this comment.
@sanil-23 hey! the code looks good to me, but CI is still pending so i'll hold off on the formal approval until those checks are green — i'll come back and approve once they pass. let me know if you need anything.
For the record: the fix is clean. Scoping the comment-skip to line.starts_with("//") and the bare-identifier fallback to anything that doesn't lead with a quote character are both minimal and correct. The new test covers both the bare-key path and the comment-skip behavior, and CodeRabbit's request for explicit test coverage on bare identifiers is addressed. Nothing in scope here touches production code.
…tream fix) Upstream PR tinyhumansai#2865 also fixed the unquoted-identifier key issue in parse_frontend_legacy_aliases (inline logic, also skips comment lines in the compact join). Resolve conflict by keeping the upstream approach and dropping the object_key() helper introduced in our branch.
Summary
Fix the
core::legacy_aliases::tests::frontend_legacy_aliases_match_server_alias_tabletest, which #2853 broke by addinghealth_snapshot: CORE_RPC_METHODS.healthSnapshot,toLEGACY_METHOD_ALIASES.Why the test was broken
Prettier strips quotes from object keys that are valid JS identifiers, so
'health_snapshot':round-trips tohealth_snapshot:. The Rust test parser'sparse_frontend_legacy_aliasesthen calledquoted_value()on the bare identifier and panicked:My first attempt was the obvious one — quote the key in
rpcMethods.ts. CI caught the next layer: Prettier'sformat:checkrejects the redundant quotes. So the fix has to be in the parser, not the source file.What this PR changes
src/core/legacy_aliases.rs—parse_frontend_legacy_aliasesonly://-comment lines when compacting theLEGACY_METHOD_ALIASESbody. Without this the first quoted key picks up the inline comment header (regression in the prior attempt; caught by full test run).'foo':continues to work; barefoo:(valid JS identifier) is now accepted too. Detection is by leading'or".Impact
This unblocks every PR rebasing onto current main. Confirmed downstream effects:
test / Rust Core Tests + Quality+Rust Core Coverage (cargo-llvm-cov)) — both this root cause.Test plan
core::legacy_aliases::tests::*pass locally (20 passed; 0 failed).app/src/services/rpcMethods.tsleft untouched — no Prettier regression.🤖 Generated with Claude Code
Summary by CodeRabbit