langchain-ai/langchain · error · ValueError

Found invalid Google-Style docstring.

Error message

Found invalid Google-Style docstring.

What it means

Error "Found invalid Google-Style docstring." thrown in langchain-ai/langchain.

Source

Thrown at libs/core/langchain_core/utils/function_calling.py:769

            invalid.

    Returns:
        A tuple of the function description and a dictionary of argument descriptions.
    """
    if docstring:
        docstring_blocks = docstring.split("\n\n")
        if error_on_invalid_docstring:
            filtered_annotations = {
                arg
                for arg in args
                if arg not in {"run_manager", "callbacks", "runtime", "return"}
            }
            if filtered_annotations and (
                len(docstring_blocks) < _MIN_DOCSTRING_BLOCKS
                or not any(block.startswith("Args:") for block in docstring_blocks[1:])
            ):
                msg = "Found invalid Google-Style docstring."
                raise ValueError(msg)
        descriptors = []
        args_block = None
        past_descriptors = False
        for block in docstring_blocks:
            if block.startswith("Args:"):
                args_block = block
                break
            if block.startswith(("Returns:", "Example:")):
                # Don't break in case Args come after
                past_descriptors = True
            elif not past_descriptors:
                descriptors.append(block)
            else:
                continue
        description = " ".join(descriptors).strip()
    else:
        if error_on_invalid_docstring:
            msg = "Found invalid Google-Style docstring."

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Rewrite the docstring in valid Google style: summary line, then 'Args:' section with 'name: description' entries.
  2. Run a Google-style docstring linter (e.g. pydocstyle with google convention) to find the malformed section.

Example fix

def f(query: str) -> str:
    """Do a thing.

    Args:
        query: The user query.
    """

When it happens

Trigger: Raised when parsing a Google-style docstring fails structurally (e.g. malformed Args section) while inferring a tool schema from a function.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/822775d0403a4bc8. Report an issue: GitHub.