Skip to content

fix: improve error message when beautifulsoup4/lxml not installed for load_web_page#4853

Open
brucearctor wants to merge 1 commit intogoogle:mainfrom
brucearctor:fix/load-web-page-import-error
Open

fix: improve error message when beautifulsoup4/lxml not installed for load_web_page#4853
brucearctor wants to merge 1 commit intogoogle:mainfrom
brucearctor:fix/load-web-page-import-error

Conversation

@brucearctor
Copy link

Description

The built-in load_web_page tool requires beautifulsoup4 and lxml, which are available via the [extensions] optional dependency group. When a user installs google-adk without the [extensions] extra and calls load_web_page, they get a raw ModuleNotFoundError: No module named 'bs4' with no guidance on how to resolve it.

This change wraps the deferred imports in a try/except to provide a clear, actionable error message:

ImportError: load_web_page requires the "beautifulsoup4" and "lxml" packages.
Install them with: pip install google-adk[extensions]

Fixes #4852

@google-cla
Copy link

google-cla bot commented Mar 17, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 user experience for the load_web_page tool by replacing a generic ModuleNotFoundError with a specific and helpful ImportError. This change ensures that users who call load_web_page without the necessary beautifulsoup4 and lxml dependencies receive clear instructions on how to resolve the issue, streamlining the setup process and reducing potential frustration.

Highlights

  • Improved Error Handling: Wrapped the beautifulsoup4 and lxml imports in load_web_page with a try/except block to catch ImportError.
  • Actionable Error Message: Provided a clear and actionable ImportError message guiding users to install the beautifulsoup4 and lxml packages via pip install google-adk[extensions] when they are missing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/tools/load_web_page.py
    • Added a try/except block to handle ImportError for beautifulsoup4 and lxml.
    • Introduced a custom ImportError message with installation instructions.
Activity
  • No human activity has been recorded on this pull request yet.
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
Contributor

@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 improves the error handling in load_web_page for cases where optional dependencies are not installed. It wraps the imports of beautifulsoup4 and lxml in a try-except block. If an ImportError is raised, it is caught and a new ImportError is raised with a more informative message that instructs the user on how to install the required packages. The change is correct and improves the user experience by providing clear, actionable guidance.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Mar 17, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Mar 17, 2026

Response from ADK Triaging Agent

Hello @brucearctor, thank you for your contribution!

Before we can merge this pull request, we need you to sign our Contributor License Agreement (CLA). You can do so by following the instructions in the "cla/google" check at the bottom of the pull request.

This is a one-time process and is required for all contributions to Google open source projects. Thanks!

… load_web_page

The load_web_page tool requires beautifulsoup4 and lxml, which are
available via the [extensions] optional dependency group. Previously,
calling the tool without these packages installed produced a raw
ModuleNotFoundError, giving no guidance on how to resolve it.

This wraps the deferred imports in try/except to provide a clear,
actionable error message directing users to install the missing
packages with: pip install google-adk[extensions]

Fixes google#4852
@brucearctor brucearctor force-pushed the fix/load-web-page-import-error branch from f1bc099 to d3b4bd9 Compare March 17, 2026 00:12
@brucearctor
Copy link
Author

should now be sorted :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

beautifulsoup4 should be a dependency of google-adk package due ot load_web_page tool

2 participants