Skip to content

Conversation

@mfts
Copy link
Owner

@mfts mfts commented Jun 18, 2025

Summary by CodeRabbit

  • New Features

    • Improved folder access for dataroom links by ensuring all parent folders are included when permissions exist on subfolders, providing a more complete folder hierarchy view.
  • Bug Fixes

    • Enhanced link retrieval to properly handle and process the dataroom identifier, ensuring accurate data representation in link responses.

@vercel
Copy link

vercel bot commented Jun 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
papermark ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2025 7:07pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

A helper function was added to recursively collect all parent folder IDs for specified folders in a dataroom. The dataroom link data fetching logic was updated to include these parent folders, ensuring hierarchical folder access. API endpoints now pass the dataroomId to this logic and handle the dataroomId property in responses.

Changes

File(s) Change Summary
lib/api/links/link-data.ts Added getAllParentFolderIds helper; updated fetchDataroomLinkData to accept dataroomId and expand folder IDs to include all parents.
pages/api/links/[id]/index.ts Updated link retrieval to include and handle dataroomId; passes dataroomId to fetchDataroomLinkData; sets dataroomId to undefined in response.
pages/api/links/domains/[...domainSlug].ts Passes dataroomId to fetchDataroomLinkData for dataroom links; no other logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant API as API Endpoint
    participant DB as Database
    participant LinkLogic as fetchDataroomLinkData
    participant Helper as getAllParentFolderIds

    API->>DB: Fetch link (includes dataroomId)
    API->>LinkLogic: fetchDataroomLinkData(folderIds, dataroomId)
    LinkLogic->>Helper: getAllParentFolderIds(folderIds, dataroomId)
    Helper->>DB: Fetch all folders in dataroom
    Helper-->>LinkLogic: Return expanded folderIds (including parents)
    LinkLogic->>DB: Fetch folders by expanded folderIds
    LinkLogic-->>API: Return dataroom link data
    API-->>Client: Respond (dataroomId set to undefined)
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-18T19_05_06_291Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d0448d and 7f8be96.

📒 Files selected for processing (3)
  • lib/api/links/link-data.ts (4 hunks)
  • pages/api/links/[id]/index.ts (3 hunks)
  • pages/api/links/domains/[...domainSlug].ts (1 hunks)
🔇 Additional comments (8)
pages/api/links/domains/[...domainSlug].ts (1)

167-167: Correct integration with updated function signature.

The addition of dataroomId parameter aligns with the updated fetchDataroomLinkData function signature and is necessary for the hierarchical folder access fix.

pages/api/links/[id]/index.ts (3)

66-66: Correct addition of dataroomId to database query.

Adding dataroomId to the Prisma select statement is necessary to provide the required parameter for the updated fetchDataroomLinkData function.


119-119: Proper parameter passing to updated function.

The dataroomId parameter is correctly passed to fetchDataroomLinkData to enable hierarchical folder access functionality.


139-139: Good security practice by removing internal ID from response.

Setting dataroomId: undefined in the response object prevents exposure of internal database IDs to API consumers while still allowing the function to use it internally.

lib/api/links/link-data.ts (4)

10-42: Well-implemented hierarchical folder resolution with good performance considerations.

The getAllParentFolderIds helper function correctly solves the hierarchical permission problem. Key strengths:

  1. Efficient data structure choice: Using Map for O(1) parent lookup is more efficient than nested iterations
  2. Proper traversal logic: The while loop correctly traverses up the hierarchy until reaching root folders
  3. Duplicate prevention: Using Set ensures no duplicate folder IDs in the result

The approach of fetching all folders upfront is reasonable since you need the complete hierarchy map to traverse efficiently.


46-56: Correct function signature update for hierarchical folder access.

Adding the dataroomId parameter with proper typing enables the function to resolve parent folder hierarchies, which is essential for the fix.


95-102: Logical and secure implementation of parent folder inclusion.

The conditional logic correctly expands folder permissions only when:

  1. Group permissions exist with actual folder access
  2. A valid dataroomId is provided
  3. There are folders to process

This ensures the expensive parent folder resolution only runs when necessary and prevents potential security issues.


155-155: I’ll check for any existing index definitions in the schema and migrations to confirm whether additional indexes are needed:

#!/bin/bash
# Extract DataroomFolder model definition from any .prisma files
rg -n -A5 -B5 "model DataroomFolder" --glob "*.prisma"
# List all multi-field index declarations in .prisma
rg -n "@@index" --glob "*.prisma"
# List any single-field index attributes in .prisma
rg -n "@index" --glob "*.prisma"
# Search for TypeORM-style @Index decorators in TS files
rg -n "@Index" --glob "*.ts"
# Search SQL migrations for CREATE INDEX statements
rg -n "CREATE INDEX" --glob "*.sql"
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mfts mfts merged commit dba8eab into main Jun 18, 2025
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2025
@mfts mfts deleted the fix/groups branch August 19, 2025 07:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants