{"record":{"id":"7782cbca2a7833cb","repo":"pathwaycom/pathway","slug":"batch-size-must-be-a-positive-integer-got-batch-7782cb","errorCode":null,"errorMessage":"batch_size must be a positive integer, got {batch_size}.","messagePattern":"batch_size must be a positive integer, got (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/pinecone/__init__.py","lineNumber":385,"sourceCode":"    else:\n        metadata_names = []\n        for col in metadata_columns:\n            if col._table is not table:\n                raise ValueError(\n                    f\"metadata column {col._name!r} does not belong to the \"\n                    f\"provided table. Pass column references from the same table, \"\n                    f\"e.g. table.{col._name}.\"\n                )\n            if col._name in (pk_name, vector_name):\n                role = \"primary_key\" if col._name == pk_name else \"vector\"\n                raise ValueError(\n                    f\"column {col._name!r} is used as the {role} and cannot also \"\n                    \"be a metadata column. Remove it from metadata_columns.\"\n                )\n            metadata_names.append(col._name)\n\n    if batch_size <= 0:\n        raise ValueError(f\"batch_size must be a positive integer, got {batch_size}.\")\n\n    if pk_name is not None:\n        _check_primary_key_dtype(pk_name, table._get_column(pk_name).dtype)\n    _check_vector_dtype(vector_name, table._get_column(vector_name).dtype)\n    for col_name in metadata_names:\n        _check_metadata_dtype(col_name, table._get_column(col_name).dtype)\n\n    resolved_api_key = (\n        api_key if api_key is not None else os.environ.get(\"PINECONE_API_KEY\")\n    )\n    if not resolved_api_key:\n        raise ValueError(\n            \"A Pinecone API key is required. Pass api_key=... or set the \"\n            \"PINECONE_API_KEY environment variable.\"\n        )\n\n    column_index = {name_: index for index, name_ in enumerate(table.column_names())}\n    vector_index = column_index[vector_name]","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/pinecone/__init__.py#L367-L403","documentation":"Raised by pw.io.pinecone.write() when batch_size is zero or negative. The value is forwarded to the engine as max_batch_size for the Pinecone upsert batches, which must contain at least one record.","triggerScenarios":"Passing batch_size=0, a negative number, or a computed value (e.g. len(some_list) that evaluates to 0, or a config-tuned value that fell to 0) to pw.io.pinecone.write().","commonSituations":"batch_size derived from environment variables or an adaptive formula; typos like batch_size=-1 meaning 'unbounded' (not supported here).","solutions":["Set a positive batch_size (typical values 50–200 for Pinecone upserts).","If batch_size is computed, clamp it: batch_size = max(1, computed).","Omit batch_size to use the connector default."],"exampleFix":"# before\npw.io.pinecone.write(t, \"docs\", vector=t.emb, api_key=k, batch_size=0)\n# after\npw.io.pinecone.write(t, \"docs\", vector=t.emb, api_key=k, batch_size=100)","handlingStrategy":"validation","validationCode":"batch_size = max(1, int(batch_size))\nassert batch_size > 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When batch_size comes from config, validate it at config-load time, not at pipeline run time.","Do not use 0 or -1 as 'unbounded' sentinels with this connector."],"tags":["pinecone","pathway","invalid-argument","batching"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}