Skip to content

Fix Parser instantiation and globals in ComponentProvider#362

Open
phillipc wants to merge 1 commit intomainfrom
fix/component-provider-parser-globals
Open

Fix Parser instantiation and globals in ComponentProvider#362
phillipc wants to merge 1 commit intomainfrom
fix/component-provider-parser-globals

Conversation

@phillipc
Copy link
Copy Markdown
Member

Summary

ComponentProvider.getComponentParams was instantiating Parser with a downcast (new (Parser as any)(node, context, this.globals)) and passing undefined as globals to .parse(). Since Parser takes no constructor arguments, the globals were silently dropped — global variables could never resolve in component params.

Changes

  • ComponentProvider.ts: Replace new (Parser as any)(node, context, this.globals) as Parser with new Parser(), and pass this.globals to .parse() instead of undefined. This matches how every other provider (BindingStringProvider, mustacheParser) uses Parser.
  • componentProviderBehaviors.ts: Add test that registers a component with params="answer: GLOBAL_CONST" where GLOBAL_CONST is provided via provider globals, verifying globals resolution in component params.

Verification

All 52 existing tests pass (chromium + happy-dom). New test passes in both environments.

Remove `as any` downcast on Parser constructor. Parser takes no
constructor arguments; context, globals, and node are parameters of
`.parse()`. The old code silently dropped `this.globals` (passed to
the no-op constructor) and sent `undefined` to `.parse()`, so global
variables could not resolve in component params.

Add test that exercises globals resolution through component params.

Adversarial review: subagent audit — no backwards-compat, disposal,
perf, or API surface concerns; fix aligns with every other provider.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@phillipc has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 10 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 10 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e55abb3b-8c07-4e2a-a40f-408991b7ea9e

📥 Commits

Reviewing files that changed from the base of the PR and between f670aa8 and 50c3b99.

📒 Files selected for processing (2)
  • packages/provider.component/spec/componentProviderBehaviors.ts
  • packages/provider.component/src/ComponentProvider.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/component-provider-parser-globals

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant