Skip to content

merge dev to main (v2.11.6) #1981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025
Merged

merge dev to main (v2.11.6) #1981

merged 2 commits into from
Feb 7, 2025

Conversation

ymc9
Copy link
Member

@ymc9 ymc9 commented Feb 7, 2025

No description provided.

Copy link
Contributor

coderabbitai bot commented Feb 7, 2025

📝 Walkthrough

Walkthrough

This pull request contains three distinct updates. The first change bumps the version number in the JetBrains IDE build configuration from 2.11.5 to 2.11.6. The second change updates the PolicyUtil class in the runtime package by modifying the signature of getFieldReadCheckSelector and refining its field-level merging logic. Finally, a new regression test is added to verify that the permission logic for accessing a user's secret field based on the publication status of associated posts is enforced correctly.

Changes

File(s) Summary of Change
packages/ide/.../build.gradle.kts Updated the version property from "2.11.5" to "2.11.6".
packages/runtime/.../policy-utils.ts Added an extra parameter to getFieldReadCheckSelector and modified injectReadCheckSelect to merge field-level selectors only if selected.
tests/.../issue-1978.test.ts Introduced a new regression test to verify that a User’s secret field is correctly exposed only when the associated Post is published.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant PolicyUtil
    Caller->>PolicyUtil: injectReadCheckSelect(args)
    Note right of PolicyUtil: Extract fieldSelection from args.select
    PolicyUtil->>PolicyUtil: Call getFieldReadCheckSelector(model, fieldSelection)
    loop Process each field in fieldLevel selectors
        alt Field is selected
            PolicyUtil->>PolicyUtil: Merge selector for field
        else Field not selected
            PolicyUtil->>PolicyUtil: Skip merging for field
        end
    end
    PolicyUtil-->>Caller: Return merged selectors
Loading

Possibly related PRs

  • chore: bump version #1961 – Involved updating the version property in the same build file, indicating a direct link in the versioning update process.
  • merge dev to main (v2.11.5) #1973 – Focused on a version bump in the same file, showcasing a consecutive update sequence at the code level.
  • chore: bump version #1980 – Also updated the version property in packages/ide/jetbrains/build.gradle.kts, aligning closely with the current changes.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/regression/tests/issue-1978.test.ts (1)

32-40: Consider adding more test cases.

While the current test cases verify the basic functionality, consider adding:

  1. A user with an unpublished post
  2. A user with multiple posts (some published, some unpublished)
 const user1 = await prisma.user.create({
     data: { id: 1, secret: 'secret', posts: { create: { id: 1, published: true } } },
 });
 const user2 = await prisma.user.create({
     data: { id: 2, secret: 'secret' },
 });
+const user3 = await prisma.user.create({
+    data: { id: 3, secret: 'secret', posts: { create: { id: 2, published: false } } },
+});
+const user4 = await prisma.user.create({
+    data: {
+        id: 4,
+        secret: 'secret',
+        posts: {
+            create: [
+                { id: 3, published: true },
+                { id: 4, published: false }
+            ]
+        }
+    },
+});

 const db = enhance();
 await expect(db.user.findFirst({ where: { id: 1 } })).resolves.toMatchObject({ secret: 'secret' });
 await expect(db.user.findFirst({ where: { id: 1 }, select: { id: true } })).resolves.toEqual({ id: 1 });

 let r = await db.user.findFirst({ where: { id: 2 } });
 expect(r.secret).toBeUndefined();
 r = await db.user.findFirst({ where: { id: 2 }, select: { id: true } });
 expect(r.secret).toBeUndefined();

+r = await db.user.findFirst({ where: { id: 3 } });
+expect(r.secret).toBeUndefined();
+
+r = await db.user.findFirst({ where: { id: 4 } });
+expect(r.secret).toBeDefined();
packages/runtime/src/enhancements/node/policy/policy-utils.ts (1)

1164-1196: Consider adding error handling for invalid field selections.

The injectReadCheckSelect method should validate the fieldSelection parameter before passing it to getFieldReadCheckSelector.

 injectReadCheckSelect(model: string, args: any) {
+    // Validate field selection
+    if (args.select && typeof args.select !== 'object') {
+        throw new Error('Invalid field selection: expected an object');
+    }
+
     // we need to recurse into relation fields before injecting the current level, because
     // injection into current level can result in relation being selected/included, which
     // can then cause infinite recursion when we visit relation later
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a1dfdcd and 9689aa0.

⛔ Files ignored due to path filters (13)
  • package.json is excluded by !**/*.json
  • packages/ide/jetbrains/package.json is excluded by !**/*.json
  • packages/language/package.json is excluded by !**/*.json
  • packages/misc/redwood/package.json is excluded by !**/*.json
  • packages/plugins/openapi/package.json is excluded by !**/*.json
  • packages/plugins/swr/package.json is excluded by !**/*.json
  • packages/plugins/tanstack-query/package.json is excluded by !**/*.json
  • packages/plugins/trpc/package.json is excluded by !**/*.json
  • packages/runtime/package.json is excluded by !**/*.json
  • packages/schema/package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • packages/server/package.json is excluded by !**/*.json
  • packages/testtools/package.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • packages/ide/jetbrains/build.gradle.kts (1 hunks)
  • packages/runtime/src/enhancements/node/policy/policy-utils.ts (2 hunks)
  • tests/regression/tests/issue-1978.test.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/ide/jetbrains/build.gradle.kts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
tests/regression/tests/issue-1978.test.ts (2)

7-21: LGTM! Well-structured schema definition.

The schema clearly defines the relationship between User and Post models, with appropriate permissions:

  • User.secret is only readable when associated posts are published
  • Both models allow all operations by default

25-30: LGTM! Good test data setup.

Test data covers both scenarios:

  • User1 with a published post
  • User2 without any posts
packages/runtime/src/enhancements/node/policy/policy-utils.ts (1)

1314-1332: LGTM! Improved field selection logic.

The changes to getFieldReadCheckSelector optimize the field-level read checks by:

  1. Only merging selectors for fields that are explicitly selected
  2. Preventing unnecessary selector merging for unselected fields

@ymc9 ymc9 merged commit 584d8af into main Feb 7, 2025
12 checks passed
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