Skip to content

Update helpers.py to check for title name as wel#113

Open
Tikkel77 wants to merge 1 commit intoteng-lin:mainfrom
Tikkel77:patch-1
Open

Update helpers.py to check for title name as wel#113
Tikkel77 wants to merge 1 commit intoteng-lin:mainfrom
Tikkel77:patch-1

Conversation

@Tikkel77
Copy link

Updated helper function resolve_partial_id to do a match on title as well, not just on ID. Also, increased length to for checking: no check was done if length was >20, updated to >50.

Potential bugs that may arise due to this change: item.title may not be available for each entity?

Updated helper function resolve_partial_id to do a match on title as well, not just on ID. Also, increased length to for checking: no check was done if length was >20, updated to >50.

Potential bugs that may arise due to this change: item.title may not be available for each entity?
@gemini-code-assist
Copy link

Summary of Changes

Hello @Tikkel77, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of ID resolution within the CLI by allowing partial IDs to be matched against an item's title in addition to its unique identifier. It also adjusts the threshold for when a partial ID is considered sufficiently long to bypass the resolution process, aiming to improve user experience and reduce ambiguity when referencing entities.

Highlights

  • ID Resolution Logic: The _resolve_partial_id helper function now attempts to match items by their title if no match is found based on the id.
  • Partial ID Length Threshold: The minimum length for a partial_id to be considered 'complete' and skip resolution has been increased from 20 characters to 50 characters.
Changelog
  • src/notebooklm/cli/helpers.py
    • Increased the partial_id length check from 20 to 50 characters to determine if resolution should be skipped.
    • Added logic to attempt matching items by their title if no matches are found using the id.
Activity
  • The pull request was opened by Tikkel77 with the title 'Update helpers.py to check for title name as wel' and a description outlining the changes and potential concerns.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the partial ID resolution to match against item titles and increases the ID length threshold. While the title matching is a good feature enhancement, a critical Denial of Service (DoS) vulnerability exists where an unhandled None value for an entity's title (especially for Source objects) can cause the CLI tool to crash. My review includes suggestions to fix this vulnerability and improve the efficiency of the matching logic.


# Do a match based on title if ther is no match on UUID:
if len(matches) == 0:
matches = [item for item in items if item.title.lower().startswith(partial_id.lower())]

Choose a reason for hiding this comment

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

security-critical critical

A critical Denial of Service (DoS) vulnerability exists in the title matching logic. The _resolve_partial_id function does not account for cases where an entity's title attribute is None, which is possible for Source entities. If a partial ID is provided that doesn't match any UUID, item.title.lower() will raise an AttributeError if item.title is None, causing the CLI tool to crash. An attacker could exploit this by sharing a notebook containing a source without a title. The suggested fix addresses this by safely handling None titles. Additionally, the current implementation iterates over the items list twice in the worst case, which could be optimized for better performance. There's also a minor typo in the new comment (ther -> there).

Suggested change
matches = [item for item in items if item.title.lower().startswith(partial_id.lower())]
matches = [item for item in items if (item.title or "").lower().startswith(partial_id.lower())]

Jah-yee added a commit to Jah-yee/notebooklm-py that referenced this pull request Mar 6, 2026
- Add title prefix matching as fallback when ID prefix match yields no results
- Improve error message to indicate both ID and title are searched
- Fix ambiguous input message wording

This resolves teng-lin#115 and teng-lin#113
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