Skip to content

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

@devteamaegis

Description

@devteamaegis

What breaks

_get_required_fields() in src/google/adk/tools/_function_parameter_parse_util.py has a bare return statement (line 437) that returns None instead of an empty list when schema.properties is falsy (empty dict or None). The return value is assigned to declaration.parameters.required in _automatic_function_calling_util.py. Any subsequent code that iterates over .required — validation, serialization, downstream processing — raises TypeError: 'NoneType' object is not iterable.

This triggers whenever a function has no non-ignored parameters (e.g. a function that only accepts tool_context with all params in ignore_params).

TypeError: 'NoneType' object is not iterable
Traceback (most recent call last):
  File ..., line 43, in <module>
    _ = [r for r in schema.required]
                    ^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

Root cause

Line 437: return (returns None) instead of return [].

Fix

One-character change: returnreturn [] on line 437 of _function_parameter_parse_util.py.

Metadata

Metadata

Labels

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

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions