Skip to content

Fix circular ESM dependency in base-action while restoring CHECK_USER_ACCESS extensibility#793

Merged
surajair merged 3 commits intocheck_user_access_actionfrom
copilot/sub-pr-792
Mar 4, 2026
Merged

Fix circular ESM dependency in base-action while restoring CHECK_USER_ACCESS extensibility#793
surajair merged 3 commits intocheck_user_access_actionfrom
copilot/sub-pr-792

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

The previous fix for the circular module dependency (base-actionactions-registerycheck-user-accessbase-action) broke extensibility: calling getUserAccess() directly bypassed the registry, preventing users from overriding CHECK_USER_ACCESS with a custom action.

Changes

  • base-action.ts: Replace static getUserAccess import with a dynamic import() inside verifyAccess(). The deferred import resolves after all modules are initialized, eliminating the circular init issue while keeping the registry delegation intact.
  • base-action.ts: Throw an explicit ActionError (ACCESS_CHECK_NOT_FOUND) if CHECK_USER_ACCESS is missing from the registry instead of silently bypassing the check.
  • get-user-access.ts: Retained as a standalone helper used by CheckUserAccessAction directly.
// verifyAccess() in ChaiBaseAction — no static import of actions-registery at module level
protected async verifyAccess(): Promise<void> {
  if (!this.context) throw new ActionError("Context not set", "CONTEXT_NOT_SET", 500);
  const { getChaiAction } = await import("./actions-registery"); // lazy — no circular init
  const checkUserAccessAction = getChaiAction("CHECK_USER_ACCESS");
  if (!checkUserAccessAction) {
    throw new ActionError("CHECK_USER_ACCESS action not registered", "ACCESS_CHECK_NOT_FOUND", 500);
  }
  checkUserAccessAction.setContext(this.context);
  await checkUserAccessAction.execute({});
}

Users can still override the default access check by registering a custom action:

registry.register("CHECK_USER_ACCESS", new MyCustomAccessAction());

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sdk Ready Ready Preview, Comment Mar 4, 2026 5:47pm

Request Review

Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 4, 2026

Deploying sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: b5d3c70
Status: ✅  Deploy successful!
Preview URL: https://c9989fa5.sdk-8n4.pages.dev
Branch Preview URL: https://copilot-sub-pr-792.sdk-8n4.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 4, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
sdk-nextjs b5d3c70 Mar 04 2026, 05:46 PM

Copilot AI changed the title [WIP] Update to address feedback on moving getUserAccess method Fix circular module dependency in base-action via standalone getUserAccess helper Mar 4, 2026
Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
Copilot AI changed the title Fix circular module dependency in base-action via standalone getUserAccess helper Fix circular ESM dependency in base-action while restoring CHECK_USER_ACCESS extensibility Mar 4, 2026
@surajair surajair merged commit e4c27e1 into check_user_access_action Mar 4, 2026
3 of 4 checks passed
@surajair surajair deleted the copilot/sub-pr-792 branch March 4, 2026 17:49
surajair added a commit that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants