{"record":{"id":"ad47f7adfc7574f1","repo":"keras-team/keras","slug":"unroll-must-be-an-positive-integer-or-boolean-r-ad47f7","errorCode":null,"errorMessage":"`unroll` must be an positive integer or boolean. Received: unroll={unroll}","messagePattern":"`unroll` must be an positive integer or boolean\\. Received: unroll=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/tensorflow/core.py","lineNumber":290,"sourceCode":"        return tree.map_structure(tf.TensorSpec.from_tensor, out)\n\n    if tree.is_nested(xs):\n        input = tree.pack_sequence_as(xs, [x[0] for x in tree.flatten(xs)])\n        fn_output_signature = get_fn_output_signature(input)\n        return tf.map_fn(f, xs, fn_output_signature=fn_output_signature)\n    else:\n        fn_output_signature = get_fn_output_signature(xs[0])\n        return tf.map_fn(f, xs, fn_output_signature=fn_output_signature)\n\n\ndef scan(f, init, xs=None, length=None, reverse=False, unroll=1):\n    # We have reimplemented `scan` to match the behavior of `jax.lax.scan`\n    # Ref: tf.scan, jax.lax.scan\n    if not callable(f):\n        raise TypeError(f\"`f` should be a callable. Received: f={f}\")\n    if not isinstance(unroll, bool):\n        if not isinstance(unroll, int) or unroll < 1:\n            raise ValueError(\n                \"`unroll` must be an positive integer or boolean. \"\n                f\"Received: unroll={unroll}\"\n            )\n    if xs is None and length is None:\n        raise ValueError(\"Got no `xs` to scan over and `length` not provided.\")\n\n    input_is_sequence = tree.is_nested(xs)\n    output_is_sequence = tree.is_nested(init)\n\n    def pack_input(x):\n        return tree.pack_sequence_as(xs, x) if input_is_sequence else x[0]\n\n    def pack_output(x):\n        return tree.pack_sequence_as(init, x) if output_is_sequence else x[0]\n\n    if xs is None:\n        xs_flat = []\n        n = int(length)","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/core.py#L272-L308","documentation":"Error \"`unroll` must be an positive integer or boolean. Received: unroll={unroll}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/tensorflow/core.py:290 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}