Skip to content

fix(_function_parameter_parse_util): return [] not None for empty schema properties#5921

Open
devteamaegis wants to merge 1 commit into
google:mainfrom
devteamaegis:fix/typeerror-nonetype-required-fields
Open

fix(_function_parameter_parse_util): return [] not None for empty schema properties#5921
devteamaegis wants to merge 1 commit into
google:mainfrom
devteamaegis:fix/typeerror-nonetype-required-fields

Conversation

@devteamaegis
Copy link
Copy Markdown

What's broken

_get_required_fields() in src/google/adk/tools/_function_parameter_parse_util.py returns None (bare return statement, line 437) when schema.properties is falsy. The caller in _automatic_function_calling_util.py assigns the result directly to declaration.parameters.required. Any code that then iterates over .required raises TypeError: 'NoneType' object is not iterable. This fires for any function whose properties dict is empty — for example, a function that only takes tool_context once it's been added to ignore_params.

Why it happens

return with no value in a list[str]-annotated function returns None instead of the expected empty list.

Fix

Line 437: changed return to return []. One character change.

Test

Added test_empty_properties_required_is_empty_list_not_none in TestBuildFunctionDeclarationLegacy. It calls _get_required_fields with an empty-properties schema and asserts the result is [] and is iterable without raising.

Fixes #5920

…pty schema properties

_get_required_fields() had a bare `return` that returned None when
schema.properties was falsy. The None was assigned to
declaration.parameters.required, causing TypeError: 'NoneType' object
is not iterable in any downstream code that iterated over .required.

Fixes google#5920
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 31, 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.

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

adk-bot commented May 31, 2026

Response from ADK Triaging Agent

Hello @devteamaegis, thank you for creating this PR!

We noticed that this PR is not fully following the contribution guidelines yet:

  • Sign our Contributor License Agreement: The Contributor License Agreement (CLA) check has failed. Before we can review and accept your contributions, you'll need to sign the Google CLA. Please visit Google CLA to sign or view your agreements.

Once the CLA is signed and the status check passes, our team will be able to review your PR. Thank you!

@rohityan rohityan self-assigned this Jun 1, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Jun 2, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

rohityan commented Jun 2, 2026

Hi @devteamaegis , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you!

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

Labels

request clarification [Status] The maintainer need clarification or more information from the author tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: _get_required_fields returns None instead of [] for empty properties, causing TypeError

3 participants