{"record":{"id":"20fcaca4d43bc562","repo":"run-llama/liteparse","slug":"pool-size-must-be-1","errorCode":null,"errorMessage":"pool_size must be >= 1","messagePattern":"pool_size must be >= 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/python/liteparse/_pool.py","lineNumber":204,"sourceCode":"        for stream in (self._proc.stdin, self._proc.stdout):\n            try:\n                if stream:\n                    stream.close()\n            except OSError:\n                pass\n\n\nclass WorkerPool:\n    \"\"\"Fixed-size pool of parse worker processes with a hard kill deadline.\"\"\"\n\n    def __init__(\n        self,\n        config: Dict[str, Any],\n        pool_size: int,\n        parse_timeout: Optional[float] = None,\n    ):\n        if pool_size < 1:\n            raise ValueError(\"pool_size must be >= 1\")\n        if parse_timeout is not None and parse_timeout <= 0:\n            raise ValueError(\"parse_timeout must be > 0 seconds\")\n        self._config = dict(config)\n        self._timeout = parse_timeout\n        self._idle: \"queue.Queue[_Worker]\" = queue.Queue()\n        self._lock = threading.Lock()\n        self._workers: List[_Worker] = []\n        self._closed = False\n        # Spawn eagerly: children import and construct their native parsers\n        # concurrently while the caller goes on with its own startup.\n        for _ in range(pool_size):\n            self._spawn_worker()\n\n    def _spawn_worker(self) -> None:\n        worker = _Worker(self._config)\n        with self._lock:\n            self._workers.append(worker)\n        self._idle.put(worker)","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/python/liteparse/_pool.py#L186-L222","documentation":"WorkerPool is a fixed-size pool of subprocess parsers; constructing it with pool_size less than 1 would create a pool that can never serve a parse, so __init__ raises ValueError immediately before spawning workers. It is a constructor-time argument validation, not a runtime failure.","triggerScenarios":"Calling WorkerPool(config, pool_size=0), a negative value, or a pool_size computed from something like len(items) on an empty collection, or an environment/config value like PARSE_POOL_SIZE that is unset-interpreted as 0.","commonSituations":"Config-driven pool sizing where an env var defaults to 0; computing pool_size as cpu_count-derived or len(batch)-based value that evaluates to 0 in tests or single-item scripts; typo passing pool_size=0 intentionally to 'disable' the pool.","solutions":["Pass an integer pool_size >= 1 when constructing WorkerPool","Clamp computed values: pool_size = max(1, computed_size)","If a config/env var feeds pool_size, validate/parse it before construction (e.g. int(os.environ.get('PARSE_POOL_SIZE', '2')))","Wrap construction in try/except ValueError to surface a clear configuration error at startup"],"exampleFix":"# before\npool = WorkerPool(config, pool_size=int(os.environ.get('PARSE_POOL_SIZE', 0)))\n# after\npool_size = max(1, int(os.environ.get('PARSE_POOL_SIZE', '2')))\npool = WorkerPool(config, pool_size=pool_size)","handlingStrategy":"validation","validationCode":"pool_size = int(raw_pool_size)\nif pool_size < 1:\n    raise ValueError(f'pool_size must be >= 1, got {pool_size}')","typeGuard":"def is_valid_pool_size(v: object) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 1","tryCatchPattern":"try:\n    pool = WorkerPool(config, pool_size=pool_size)\nexcept ValueError as e:\n    raise ConfigError(f'invalid liteparse pool configuration: {e}') from e","preventionTips":["Never compute pool_size from possibly-empty collections; use max(1, n)","Give env/config-driven sizes a safe default (e.g. 2) and clamp with max(1, value)","Validate all pool settings at application startup, not lazily","Exclude bool from int coercion (True == 1) when parsing config"],"tags":["python","configuration","validation","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}