Skip to content

refactor: optimize CedarPermissionsService for batched access level c… - #1889

Merged
Artuomka merged 1 commit into
mainfrom
backend_cedar_permission_n_plus_one
Oct 12, 2026
Merged

Artuomka merged 1 commit into
mainfrom
backend_cedar_permission_n_plus_one

Conversation

@Artuomka

@Artuomka Artuomka commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

…hecks

  • Introduced methods for evaluating connection and group access levels in a batched manner to reduce database queries.
  • Replaced individual access level checks with batched counterparts in various use cases, improving performance.
  • Updated the getReadableTables method to cache results and minimize repeated group lookups.
  • Enhanced tests to cover new batched functionality and ensure consistent permission checks across different scenarios.

Summary by CodeRabbit

  • Improvements
    • Table and group access checks are now handled in batches across database queries, AI tools, and connection views.
    • Query results and related-table details continue to be limited to tables you can access; unreadable tables are rejected.
    • Access checks reuse prior results, helping reduce repeated permission lookups.

…hecks

- Introduced methods for evaluating connection and group access levels in a batched manner to reduce database queries.
- Replaced individual access level checks with batched counterparts in various use cases, improving performance.
- Updated the `getReadableTables` method to cache results and minimize repeated group lookups.
- Enhanced tests to cover new batched functionality and ensure consistent permission checks across different scenarios.
@Artuomka
Artuomka enabled auto-merge October 12, 2026 13:25
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95939f1f-270f-4ac0-96de-e70915596ce2

📥 Commits

Reviewing files that changed from the base of the PR and between 1956c45 and e536c03.


📒 Files selected for processing (16)
  • backend/src/entities/ai/use-cases/request-info-from-table-with-ai-v7.use.case.ts
  • backend/src/entities/cedar-authorization/cedar-permissions.service.ts
  • backend/src/entities/connection/use-cases/find-one-connection.use.case.ts
  • backend/src/entities/connection/use-cases/get-user-groups-in-connection.use.case.ts
  • backend/src/entities/group/repository/group-custom-repository-extension.ts
  • backend/src/entities/group/use-cases/find-all-user-groups.use.case.ts
  • backend/src/entities/table/utils/filter-foreign-keys-by-permission.util.ts
  • backend/src/entities/table/utils/process-referenced-tables.util.ts
  • backend/src/entities/user-access/repository/user-access.repository.interface.ts
  • backend/src/entities/visualizations/panel/use-cases/execute-panel.use.case.ts
  • backend/src/entities/visualizations/panel/use-cases/test-db-query.use.case.ts
  • backend/src/entities/visualizations/panel/utils/assert-query-tables-readable.util.ts
  • backend/src/microservices/agents-microservice/use-cases/execute-ai-raw-query.use.case.ts
  • backend/src/microservices/agents-microservice/use-cases/get-ai-connection-tables.use.case.ts
  • backend/src/microservices/agents-microservice/utils/ai-data-access.helpers.ts
  • backend/test/ava-tests/unit-tests/cedar-permissions-batched-checks.test.ts

 _______________________________
< Copilot: Off. CodeRabbit: On. >
 -------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@Artuomka
Artuomka merged commit 69b61ea into main Oct 12, 2026
15 of 17 checks passed
@Artuomka
Artuomka deleted the backend_cedar_permission_n_plus_one branch October 12, 2026 13:31
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.

1 participant