{"record":{"id":"c76509b9a341733a","repo":"keras-team/keras","slug":"the-salt-argument-for-indexlookup-can-only-be","errorCode":null,"errorMessage":"The `salt` argument for `IndexLookup` can only be a tuple of 2 integers, or a single integer. Received: salt={salt}.","messagePattern":"The `salt` argument for `IndexLookup` can only be a tuple of 2 integers, or a single integer\\. Received: salt=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/index_lookup.py","lineNumber":171,"sourceCode":"            caller_name=self.__class__.__name__,\n            arg_name=\"oov_method\",\n        )\n\n        if salt is not None:\n            if (\n                tf.as_dtype(vocabulary_dtype).is_integer\n                and oov_method != \"farmhash\"\n            ):\n                raise ValueError(\n                    \"`salt` can only be used when `oov_method='farmhash'`. \"\n                    f\"Received: oov_method={oov_method}\"\n                )\n            if isinstance(salt, (tuple, list)) and len(salt) == 2:\n                salt = list(salt)\n            elif isinstance(salt, int):\n                salt = [salt, salt]\n            else:\n                raise ValueError(\n                    \"The `salt` argument for `IndexLookup` can only be a tuple \"\n                    \"of 2 integers, or a single integer. \"\n                    f\"Received: salt={salt}.\"\n                )\n\n        # Support deprecated names for output_modes.\n        if output_mode == \"binary\":\n            output_mode = \"multi_hot\"\n        if output_mode == \"tf-idf\":\n            output_mode = \"tf_idf\"\n        argument_validation.validate_string_arg(\n            output_mode,\n            allowable_strings=(\n                \"int\",\n                \"one_hot\",\n                \"multi_hot\",\n                \"count\",\n                \"tf_idf\",","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/index_lookup.py#L153-L189","documentation":"The `salt` argument accepts either a single integer (used for both FarmHash salt values) or a tuple/list of exactly two integers. Any other type or length cannot map onto FarmHash's salt pair and is rejected.","triggerScenarios":"`salt='seed'`, `salt=[1, 2, 3]`, `salt=(1, 'a')`, or a numpy scalar / string from a config file.","commonSituations":"Passing seeds loaded from YAML/JSON config as strings, or reusing a 3-element seed tuple from another hashing library.","solutions":["Pass an int: `salt=42` (applied to both salt slots).","Or a 2-element tuple/list of ints: `salt=(42, 43)`.","Coerce config values before use: `salt=int(cfg['seed'])`."],"exampleFix":"# before\nlayer = IndexLookup(salt=(42, 43, 44), oov_method='farmhash')\n\n# after\nlayer = IndexLookup(salt=(42, 43), oov_method='farmhash')","handlingStrategy":"type-guard","validationCode":"if salt is not None:\n    assert isinstance(salt, int) or (isinstance(salt, (tuple, list)) and len(salt) == 2 and all(isinstance(x, int) for x in salt)), 'bad salt: %r' % salt","typeGuard":"def is_valid_salt(v) -> bool:\n    if isinstance(v, bool):\n        return False\n    if isinstance(v, int):\n        return True\n    return isinstance(v, (tuple, list)) and len(v) == 2 and all(isinstance(x, int) and not isinstance(x, bool) for x in v)","tryCatchPattern":null,"preventionTips":["Coerce seeds from config files to int before passing them.","Never forward untyped seed values from other libraries."],"tags":["keras","preprocessing","index-lookup","argument-validation","type-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}