{"record":{"id":"aa67403bf336f8f8","repo":"langchain-ai/langchain","slug":"batch-size-must-be-a-positive-integer-got-size-aa6740","errorCode":null,"errorMessage":"Batch size must be a positive integer, got {size}.","messagePattern":"Batch size must be a positive integer, got (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/utils/iter.py","lineNumber":223,"sourceCode":"\ndef batch_iterate(size: int | None, iterable: Iterable[T]) -> Iterator[list[T]]:\n    \"\"\"Utility batching function.\n\n    Args:\n        size: The size of the batch.\n\n            If `None`, returns a single batch.\n        iterable: The iterable to batch.\n\n    Yields:\n        The batches of the iterable.\n\n    Raises:\n        ValueError: If `size` is not `None` and is not a positive integer.\n    \"\"\"\n    if size is not None and size <= 0:\n        msg = f\"Batch size must be a positive integer, got {size}.\"\n        raise ValueError(msg)\n    it = iter(iterable)\n    while True:\n        chunk = list(islice(it, size))\n        if not chunk:\n            return\n        yield chunk\n","sourceCodeStart":205,"sourceCodeEnd":230,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/utils/iter.py#L205-L230","documentation":"Error \"Batch size must be a positive integer, got {size}.\" thrown in langchain-ai/langchain.","triggerScenarios":"Raised when a batch() helper is called with a batch size that is not a positive integer (zero or negative).","commonSituations":"See trigger scenarios.","solutions":["Pass a batch size that is a positive integer (>= 1).","If the size comes from configuration, validate it before calling batching."],"exampleFix":"for chunk in batch_iterate(size=max(1, batch_size), iterable=items): ...","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}