Skip to content

fix(legacy_aliases): tolerate unquoted keys + skip comments in alias-table parser#2865

Merged
sanil-23 merged 3 commits into
tinyhumansai:mainfrom
sanil-23:fix/legacy-alias-health-snapshot-quote
May 28, 2026
Merged

fix(legacy_aliases): tolerate unquoted keys + skip comments in alias-table parser#2865
sanil-23 merged 3 commits into
tinyhumansai:mainfrom
sanil-23:fix/legacy-alias-health-snapshot-quote

Conversation

@sanil-23
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 commented May 28, 2026

Summary

Fix the core::legacy_aliases::tests::frontend_legacy_aliases_match_server_alias_table test, which #2853 broke by adding health_snapshot: CORE_RPC_METHODS.healthSnapshot, to LEGACY_METHOD_ALIASES.

Why the test was broken

Prettier strips quotes from object keys that are valid JS identifiers, so 'health_snapshot': round-trips to health_snapshot:. The Rust test parser's parse_frontend_legacy_aliases then called quoted_value() on the bare identifier and panicked:

expected quoted value in `health_snapshot`

My first attempt was the obvious one — quote the key in rpcMethods.ts. CI caught the next layer: Prettier's format:check rejects the redundant quotes. So the fix has to be in the parser, not the source file.

What this PR changes

src/core/legacy_aliases.rsparse_frontend_legacy_aliases only:

  1. Skip //-comment lines when compacting the LEGACY_METHOD_ALIASES body. Without this the first quoted key picks up the inline comment header (regression in the prior attempt; caught by full test run).
  2. Accept both quoted and bare-identifier keys. 'foo': continues to work; bare foo: (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 plan

  • All 20 core::legacy_aliases::tests::* pass locally (20 passed; 0 failed).
  • app/src/services/rpcMethods.ts left untouched — no Prettier regression.
  • CI green on this PR before merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved robustness of legacy-alias parsing tests: now tolerate comment lines and accept legacy keys written as bare identifiers or quoted strings, with added coverage to assert these behaviors.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@sanil-23, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5acc8424-6abc-46da-94ae-38a4e4a92233

📥 Commits

Reviewing files that changed from the base of the PR and between 857c389 and 2238e71.

📒 Files selected for processing (1)
  • src/core/legacy_aliases.rs
📝 Walkthrough

Walkthrough

The Rust test helper in src/core/legacy_aliases.rs now skips // comment lines when compacting the frontend LEGACY_METHOD_ALIASES body and accepts legacy keys as either quoted strings or bare JavaScript identifiers, normalizing both before resolving aliases. A unit test covers these behaviors.

Changes

Legacy Alias Parser Robustness

Layer / File(s) Summary
Comment filtering and bare identifier key handling
src/core/legacy_aliases.rs
Compacting the LEGACY_METHOD_ALIASES object now filters // comment lines as well as blank lines. The alias-entry parser accepts quoted string keys ('foo':) and bare JS identifier keys (foo:), converting bare identifiers to string keys before resolving mapped targets. A unit test verifies both behaviors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • graycyrus

Poem

🐰 I nibbled lines of code so neat,

Skipping comments, keys now meet,
Quoted or bare, they all align,
Tests hop through and say "it's fine!" 🥕

🚥 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 title accurately summarizes the main changes: fixing the legacy_aliases parser to tolerate unquoted keys and skip comments, which directly addresses the core issue described in the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 80.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.

@coderabbitai coderabbitai Bot added rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. working A PR that is being worked on by the team. labels May 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 28, 2026
…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>
@sanil-23 sanil-23 force-pushed the fix/legacy-alias-health-snapshot-quote branch from c2f8433 to 152dbb2 Compare May 28, 2026 18:31
@sanil-23 sanil-23 changed the title fix(rpc): quote health_snapshot key in LEGACY_METHOD_ALIASES fix(legacy_aliases): tolerate unquoted keys + skip comments in alias-table parser May 28, 2026
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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c2f8433 and 152dbb2.

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

Comment thread 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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

@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.

@sanil-23 sanil-23 self-assigned this May 28, 2026
@sanil-23 sanil-23 merged commit 29aeba8 into tinyhumansai:main May 28, 2026
33 of 34 checks passed
M3gA-Mind added a commit to CodeGhost21/openhuman that referenced this pull request May 28, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. working A PR that is being worked on by the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants