Skip to content
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

🔧 Make projectId nullable in OverallReview table. #904

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

FunamaYukina
Copy link
Member

@FunamaYukina FunamaYukina commented Mar 14, 2025

Issue

Since the projectId is passed as undefined at the beginning of the job, we have taken action to make it nullable to avoid errors when saving the OverallReview.

// Queue the savePullRequest task
await savePullRequestTask.trigger({
pullRequestNumber: pullRequest.number,
projectId: undefined,
owner: data.repository.owner.login,
name: data.repository.name,
repositoryId: repository.id,
})

Why is this change needed?

What would you like reviewers to focus on?

Testing Verification

We can run: pnpm test:vitest at frontend/apps/app

What was done

🤖 Generated by PR Agent at a178022

  • Made projectId nullable in OverallReview table to prevent errors.
  • Updated tests to handle nullable projectId scenarios.
  • Adjusted logic in processSaveReview to account for optional projectId.
  • Added migration script to modify database schema for OverallReview.

Detailed Changes

Relevant files
Tests
1 files
postComment.test.ts
Updated tests to handle nullable `projectId`.                       
+5/-5     
Enhancement
1 files
processSaveReview.ts
Adjusted logic to handle optional `projectId`.                     
+11/-10 
Bug fix
1 files
jobs.ts
Set `projectId` to undefined in task payload.                       
+1/-1     
Dependencies
2 files
package.json
Added `@prisma/client` dependency.                                             
+1/-0     
pnpm-lock.yaml
Updated lockfile to include `@prisma/client` dependency. 
+3/-0     
Configuration changes
2 files
migration.sql
Added migration to make `projectId` nullable in `OverallReview`.
+8/-0     
schema.prisma
Updated schema to make `projectId` nullable in `OverallReview`.
+2/-2     

Additional Notes


Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link

    changeset-bot bot commented Mar 14, 2025

    ⚠️ No Changeset found

    Latest commit: a178022

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

    Copy link

    vercel bot commented Mar 14, 2025

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

    Name Status Preview Comments Updated (UTC)
    liam-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 10:10am
    liam-erd-sample ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 10:10am
    3 Skipped Deployments
    Name Status Preview Comments Updated (UTC)
    test-liam-docs ⬜️ Ignored (Inspect) Mar 14, 2025 10:10am
    test-liam-erd-sample ⬜️ Ignored (Inspect) Mar 14, 2025 10:10am
    test-liam-erd-web ⬜️ Ignored (Inspect) Mar 14, 2025 10:10am

    Copy link

    supabase bot commented Mar 14, 2025

    Updates to Preview Branch (make-projectId-nullable-in-OverallReview-table) ↗︎

    Deployments Status Updated
    Database Fri, 14 Mar 2025 10:00:18 UTC
    Services Fri, 14 Mar 2025 10:00:18 UTC
    APIs Fri, 14 Mar 2025 10:00:18 UTC

    Tasks are run on every commit but only new migration files are pushed.
    Close and reopen this PR if you want to apply changes from existing seed or migration files.

    Tasks Status Updated
    Configurations Fri, 14 Mar 2025 10:00:24 UTC
    Migrations Fri, 14 Mar 2025 10:00:24 UTC
    Seeding Fri, 14 Mar 2025 10:00:24 UTC
    Edge Functions Fri, 14 Mar 2025 10:00:24 UTC

    View logs for this Workflow Run ↗︎.
    Learn more about Supabase for Git ↗︎.

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Type Casting

    The use of type casting with as Prisma.OverallReviewCreateInput might be hiding potential type errors. Consider using proper conditional types instead of forcing the type.

    } as Prisma.OverallReviewCreateInput,
    Undefined Value

    Setting projectId: undefined explicitly might cause issues. Consider passing null instead since the schema now expects a nullable value, not undefined.

    projectId: undefined,

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix incorrect parameter value

    The projectId is being set to undefined in the postCommentTask.trigger() call,
    but based on the PR changes, it should be passing payload.projectId which can
    now be null. This inconsistency could cause issues with comment posting.

    frontend/apps/app/src/trigger/jobs.ts [67-72]

     await postCommentTask.trigger({
       reviewComment: payload.reviewComment,
    -  projectId: undefined,
    +  projectId: payload.projectId,
       pullRequestId: payload.pullRequestId,
       repositoryId: payload.repositoryId,
     })
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: The suggestion correctly identifies a critical inconsistency where projectId is hardcoded to undefined instead of passing payload.projectId. This contradicts the PR's purpose of making projectId optional (null) and could cause functional issues with comment posting.

    High
    • More

    Copy link
    Member

    @NoritakaIkeda NoritakaIkeda left a comment

    Choose a reason for hiding this comment

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

    LGTM!

    Comment on lines +22 to +30
    ...(payload.projectId
    ? {
    project: {
    connect: {
    id: payload.projectId,
    },
    },
    }
    : {}),
    Copy link
    Member

    Choose a reason for hiding this comment

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

    Changed the logic to avoid throwing an error when projectId is undefined and to skip connecting the project instead

    @NoritakaIkeda NoritakaIkeda added this pull request to the merge queue Mar 14, 2025
    Merged via the queue into main with commit 36d93ed Mar 14, 2025
    21 checks passed
    @NoritakaIkeda NoritakaIkeda deleted the make-projectId-nullable-in-OverallReview-table branch March 14, 2025 10:24
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants