Skip to content

fix: handle missing concluded license in project license summary card#611

Merged
a-oren merged 1 commit into
guacsec:mainfrom
a-oren:TC-4504
May 19, 2026
Merged

fix: handle missing concluded license in project license summary card#611
a-oren merged 1 commit into
guacsec:mainfrom
a-oren:TC-4504

Conversation

@a-oren
Copy link
Copy Markdown
Contributor

@a-oren a-oren commented May 19, 2026

Summary

  • Fix TypeError: Cannot read properties of undefined (reading 'category') crash in the HTML report when analyzing Cargo workspace projects with local path dependencies and a project license defined
  • Add null check for p.concluded in countMoreRestrictiveThan() in SummaryCard.tsx before accessing .category

Root Cause

The countMoreRestrictiveThan() function in SummaryCard.tsx iterates all packages in the license report and accesses p.concluded.category without checking if concluded exists. For Cargo workspace local path dependencies (repository_url=local), deps.dev cannot resolve license data, so concluded is undefined. When a project license is also defined (e.g. license = "MIT" in Cargo.toml), the Project License card renders and calls this function, causing the React app to crash with no error boundary — resulting in a blank/black page in the VS Code webview.

Test plan

  • Verified the fix with nautilus_trader (large Cargo workspace with 42 local path deps and license = "LGPL-3.0-or-later")
  • Verified the fix with a minimal virtual workspace with local path deps and a [workspace.package] license field
  • Confirmed Maven/npm reports are unaffected (no regression)

Fixes: TC-4504

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Handle missing concluded license objects in license report packages to avoid TypeErrors when computing more restrictive licenses in the summary card.

Skip packages with undefined `concluded` field in `countMoreRestrictiveThan()`
to prevent React crash when rendering Cargo workspace reports with local path
dependencies that have no license data from deps.dev.

Fixes: TC-4504

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 19, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a null check for missing concluded license data in the project license summary card to prevent crashes when rendering HTML reports, and regenerates the bundled main.js asset accordingly.

Flow diagram for updated countMoreRestrictiveThan null check

flowchart TD
  A[SummaryCard render] --> B[getCategoryRank projectCategory]
  B --> C[countMoreRestrictiveThan]
  C --> D[Iterate packages]
  D --> E{p.concluded exists?}
  E -- No --> D
  E -- Yes --> F[getCategoryRank p.concluded.category]
  F --> G{packageRank < projectRank}
  G -- Yes --> H[Increment count]
  G -- No --> D
  H --> D
  D --> I[Return count]
Loading

File-Level Changes

Change Details Files
Prevent crash in SummaryCard when a package has no concluded license.
  • Update countMoreRestrictiveThan to skip packages where concluded is undefined before reading its category.
  • Ensure the loop over packages only computes ranks for packages with valid concluded license data.
ui/src/components/SummaryCard.tsx
Regenerate built frontend bundle to include the SummaryCard null-check fix.
  • Update generated main.js bundle to reflect the new guard around p.concluded in SummaryCard.
src/main/resources/freemarker/templates/generated/main.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@a-oren a-oren requested a review from ruromero May 19, 2026 13:54
@a-oren a-oren merged commit b6feaf7 into guacsec:main May 19, 2026
3 checks passed
@a-oren a-oren deleted the TC-4504 branch May 19, 2026 15:37
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.

2 participants