Skip to content

refactor: move getUserAccess method from ChaiBaseAction to CheckUserAccessAction#792

Merged
surajair merged 5 commits intodevfrom
check_user_access_action
Mar 4, 2026
Merged

refactor: move getUserAccess method from ChaiBaseAction to CheckUserAccessAction#792
surajair merged 5 commits intodevfrom
check_user_access_action

Conversation

@surajair
Copy link
Copy Markdown
Collaborator

@surajair surajair commented Mar 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 4, 2026 17:23
@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:51pm

Request Review

@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 e4c27e1 Mar 04 2026, 05:50 PM

@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: e4c27e1
Status:⚡️  Build in progress...

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors access checking by moving the getUserAccess DB lookup out of ChaiBaseAction and into CheckUserAccessAction, and updates ChaiBaseAction.verifyAccess() to delegate authorization checks through the action registry.

Changes:

  • Added getUserAccess() implementation to CheckUserAccessAction (DB query + error handling).
  • Removed getUserAccess() from ChaiBaseAction and rewired verifyAccess() to call CHECK_USER_ACCESS via getChaiAction.
  • Updated imports accordingly (DB/drizzle imports moved off of base-action.ts).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/actions/builder/check-user-access.ts Introduces getUserAccess() and makes execute() rely on it to validate app/user access.
src/actions/builder/base-action.ts Removes inline DB access check and delegates authorization to the registry action CHECK_USER_ACCESS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/actions/builder/base-action.ts Outdated
Comment thread src/actions/builder/check-user-access.ts Outdated
Comment on lines 2 to 4
import { ActionError } from "./action-error";
import { getChaiAction } from "./actions-registery";
import { ChaiAction, ChaiActionContext } from "./chai-action-interface";
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

verifyAccess() now depends on getChaiAction from actions-registery, which imports (and instantiates) actions that themselves extend ChaiBaseAction. This creates a circular module dependency (base-action -> actions-registery -> check-user-access -> base-action) that can break ESM module initialization (e.g., ChaiBaseAction being undefined when CheckUserAccessAction is evaluated). To avoid this, keep verifyAccess self-contained (DB check here) or invert the dependency (e.g., inject an access-check function/instance from the caller/handler rather than importing the registry in the base class).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

@surajair I've opened a new pull request, #793, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits March 4, 2026 17:36
Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
Fix circular ESM dependency in base-action while restoring CHECK_USER_ACCESS extensibility
@surajair surajair merged commit 9693736 into dev Mar 4, 2026
2 of 4 checks passed
@surajair surajair deleted the check_user_access_action branch March 4, 2026 17:51
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.

3 participants