liam icon indicating copy to clipboard operation
liam copied to clipboard

🔧 Resolving 404 errors when there are no records in `overallreview`

Open FunamaYukina opened this issue 7 months ago • 5 comments
trafficstars

Implemented graceful fallback for migrations without review data, replacing 404 errors with empty states and informative messages while preserving core migration information display.

✅ local check

When there is a record of migration but no record of review:

ss 3047

Before: 404

ss 3045

After: browse page ss 3046

Issue

  • resolve:

Why is this change needed?

What would you like reviewers to focus on?

Testing Verification

What was done

🤖 Generated by PR Agent at 3822e50875315cad5fd1f30c7a545ced57d04074

  • Implemented fallback for missing overallReview data, avoiding 404 errors.
  • Enhanced display logic for review scores and comments.
  • Improved error handling for schema path fetching.
  • Added user-friendly messages for missing review data.

Detailed Changes

Relevant files
Enhancement
MigrationDetailPage.tsx
Enhanced handling and display of migration review data     

frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx

  • Added fallback logic for missing overallReview data.
  • Updated display logic to handle absent review scores and comments.
  • Improved error handling for schema path fetching.
  • Added user-friendly messages for missing review content.
  • +61/-32 

    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.
  • FunamaYukina avatar Apr 04 '25 09:04 FunamaYukina

    ⚠️ No Changeset found

    Latest commit: 3822e50875315cad5fd1f30c7a545ced57d04074

    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

    changeset-bot[bot] avatar Apr 04 '25 09:04 changeset-bot[bot]

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

    Name Status Preview Comments Updated (UTC)
    liam-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 4, 2025 9:57am
    liam-erd-sample ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 4, 2025 9:57am
    1 Skipped Deployment
    Name Status Preview Comments Updated (UTC)
    liam-docs ⬜️ Ignored (Inspect) Visit Preview Apr 4, 2025 9:57am

    vercel[bot] avatar Apr 04 '25 09:04 vercel[bot]

    Updates to Preview Branch (handle-missing-overall-review) ↗︎

    Deployments Status Updated
    Database Fri, 04 Apr 2025 09:30:33 UTC
    Services Fri, 04 Apr 2025 09:30:33 UTC
    APIs Fri, 04 Apr 2025 09:30:33 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, 04 Apr 2025 09:30:40 UTC
    Migrations Fri, 04 Apr 2025 09:30:42 UTC
    Seeding Fri, 04 Apr 2025 09:30:42 UTC
    Edge Functions Fri, 04 Apr 2025 09:30:42 UTC

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

    supabase[bot] avatar Apr 04 '25 09:04 supabase[bot]

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Conditional Rendering

    The UserFeedbackClient component is only rendered when overallReview.traceId exists, but there's no explicit check for this property in the empty review data object created when no review is found.

    {overallReview.traceId && (
      <div className={styles.feedbackSection}>
        <UserFeedbackClient traceId={overallReview.traceId} />
      </div>
    )}
    

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Avoid unnecessary database query

    The code is using overallReview.projectId || 0 which could cause issues when
    projectId is null. Since you're handling cases where overallReview might not
    have data, consider skipping this database query entirely when projectId is null
    to avoid unnecessary database calls.

    frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx [105-108]

    -const { data: schemaPaths, error: pathsError } = await supabase
    -  .from('GitHubSchemaFilePath')
    -  .select('path')
    -  .eq('projectId', overallReview.projectId || 0)
    +// Skip schema paths query if no projectId is available
    +let schemaPaths = [];
    +let pathsError = null;
     
    +if (overallReview.projectId) {
    +  const result = await supabase
    +    .from('GitHubSchemaFilePath')
    +    .select('path')
    +    .eq('projectId', overallReview.projectId);
    +  
    +  schemaPaths = result.data || [];
    +  pathsError = result.error;
    +}
    +
    
    • [ ] Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: This suggestion improves efficiency by avoiding unnecessary database queries when projectId is null. It also prevents potential issues with the fallback to 0, which could match unrelated records in the database.

    Medium
    Possible issue
    Add null check

    The code assumes overallReview.reviewScores is always an array. However, when
    creating a default overallReview object earlier in the code, you set
    reviewScores: [], but there's no type checking. Add a null check to prevent
    potential runtime errors.

    frontend/apps/app/features/migrations/pages/MigrationDetailPage/MigrationDetailPage.tsx [173-186]

    -{overallReview.reviewScores.length > 0 ? (
    +{(overallReview.reviewScores && overallReview.reviewScores.length > 0) ? (
       <div className={styles.radarChartContainer}>
         <RadarChart
           scores={overallReview.reviewScores.map((score) => ({
             id: score.id,
             overallReviewId: score.overallReviewId,
             overallScore: score.overallScore,
             category: score.category as CategoryEnum,
           }))}
         />
       </div>
     ) : (
       <p className={styles.noScores}>No review scores found.</p>
     )}
    
    • [ ] Apply this suggestion
    Suggestion importance[1-10]: 6

    __

    Why: The suggestion adds a defensive null check that prevents potential runtime errors if reviewScores is unexpectedly null or undefined, improving the robustness of the code. This is a good defensive programming practice.

    Low
    • [ ] More