Skip to content

OpenAPI query parameters drop explicit false and zero values #6287

Description

@VectorPeak

🔴 Required Information

Please ensure all items in this section are completed to allow for efficient
triaging. Requests without complete information may be rejected / deprioritized.
If an item is not applicable to you - please mark it as N/A

Describe the Bug:
RestApiTool._prepare_request_params() drops explicit falsy OpenAPI query parameter values such as False and 0 when building request_params["params"].

The current filtering treats absent values and caller-provided falsy values the same way. This can change request behavior for APIs that distinguish an omitted query parameter from an explicit value such as false or 0.

Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:

  1. Define an OpenAPI operation with query parameters such as a boolean filter and a numeric pagination parameter.
  2. Invoke the generated REST tool with explicit falsy values, for example:
    {
        "include_inactive": False,
        "page": 0,
        "empty_param": "",
    }
  3. Inspect the params produced by RestApiTool._prepare_request_params() before request execution.

Expected Behavior:
Explicit falsy-but-valid query parameter values should be preserved in request_params["params"], for example:

{
    "includeInactive": False,
    "page": 0,
}

Empty string values may continue to be omitted if that is the existing intended behavior.

Observed Behavior:
Falsy query parameter values are omitted from request_params["params"] because the query parameter collection path filters with a truthiness check.

As a result, values such as False and 0 do not reach the existing httpx.AsyncClient.request(..., params=...) path.

Environment Details:

  • ADK Library Version (pip show google-adk): N/A
  • Desktop OS:** N/A
  • Python Version (python -V): N/A

Model Information:

  • Are you using LiteLLM: N/A
  • Which model is being used: N/A

🟡 Optional Information

Providing this information greatly speeds up the resolution process.

Regression:
N/A

Logs:
N/A

Screenshots / Video:
N/A

Additional Context:
This affects generated REST tools for OpenAPI operations where query parameters intentionally use falsy values. Common examples include boolean filters and pagination-style parameters:

includeInactive=false
page=0
limit=0

A fix is proposed in PR #6286.

Minimal Reproduction Code:
Please provide a code snippet or a link to a Gist/repo that isolates the issue.

api_args = {
    "include_inactive": False,
    "page": 0,
    "empty_param": "",
}

# Expected:
# False and 0 are preserved in request_params["params"].
# Empty string remains omitted if preserving existing behavior.

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions