{"record":{"id":"d54340666f96b1dc","repo":"keras-team/keras","slug":"output-sequence-length-must-be-either-none-or-an","errorCode":null,"errorMessage":"`output_sequence_length` must be either None or an integer when `output_mode` is 'int'. Received: output_sequence_length={output_sequence_length}","messagePattern":"`output_sequence_length` must be either None or an integer when `output_mode` is 'int'\\. Received: output_sequence_length=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/text_vectorization.py","lineNumber":305,"sourceCode":"        # 'ngrams' must be one of (None, int, tuple(int))\n        if not (\n            ngrams is None\n            or isinstance(ngrams, int)\n            or isinstance(ngrams, tuple)\n            and all(isinstance(item, int) for item in ngrams)\n        ):\n            raise ValueError(\n                \"`ngrams` must be None, an integer, or a tuple of \"\n                f\"integers. Received: ngrams={ngrams}\"\n            )\n\n        # 'output_sequence_length' must be one of (None, int) and is only\n        # set if output_mode is \"int\"\".\n        if output_mode == \"int\" and not (\n            isinstance(output_sequence_length, int)\n            or (output_sequence_length is None)\n        ):\n            raise ValueError(\n                \"`output_sequence_length` must be either None or an \"\n                \"integer when `output_mode` is 'int'. Received: \"\n                f\"output_sequence_length={output_sequence_length}\"\n            )\n\n        if output_mode != \"int\" and output_sequence_length is not None:\n            raise ValueError(\n                \"`output_sequence_length` must not be set if `output_mode` is \"\n                \"not 'int'. \"\n                f\"Received output_sequence_length={output_sequence_length}.\"\n            )\n\n        if ragged and output_mode != \"int\":\n            raise ValueError(\n                \"`ragged` must not be true if `output_mode` is \"\n                f\"`'int'`. Received: ragged={ragged} and \"\n                f\"output_mode={output_mode}\"\n            )","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/text_vectorization.py#L287-L323","documentation":"Error \"`output_sequence_length` must be either None or an integer when `output_mode` is 'int'. Received: output_sequence_length={output_sequence_length}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/text_vectorization.py:305 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"}