{"record":{"id":"fc5baf2f46344780","repo":"keras-team/keras","slug":"expected-variables-to-be-a-list-tuple-set-recei","errorCode":null,"errorMessage":"Expected `variables` to be a list/tuple/set. Received instead object of type '{type(variables)}'.","messagePattern":"Expected `variables` to be a list/tuple/set\\. Received instead object of type '(.+?)'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/export/saved_model_export_archive.py","lineNumber":225,"sourceCode":"        # Register an endpoint\n        export_archive.add_endpoint(\n            name=\"serve\",\n            fn=model.call,\n            input_signature=[keras.InputSpec(shape=(None, 3), dtype=\"float32\")],\n        )\n        # Save a variable collection\n        export_archive.add_variable_collection(\n            name=\"optimizer_variables\", variables=model.optimizer.variables)\n        export_archive.write_out(\"path/to/location\")\n\n        # Reload the object\n        revived_object = tf.saved_model.load(\"path/to/location\")\n        # Retrieve the variables\n        optimizer_variables = revived_object.optimizer_variables\n        ```\n        \"\"\"\n        if not isinstance(variables, (list, tuple, set)):\n            raise ValueError(\n                \"Expected `variables` to be a list/tuple/set. \"\n                f\"Received instead object of type '{type(variables)}'.\"\n            )\n        # Ensure that all variables added are either tf.Variables\n        # or Variables created by Keras 3 with the TF or JAX backends.\n        if not all(\n            isinstance(v, (tf.Variable, backend.Variable)) for v in variables\n        ):\n            raise ValueError(\n                \"Expected all elements in `variables` to be \"\n                \"`tf.Variable` instances. Found instead the following types: \"\n                f\"{list(set(type(v) for v in variables))}\"\n            )\n        if backend.backend() == \"jax\":\n            variables = tree.flatten(\n                tree.map_structure(self._convert_to_tf_variable, variables)\n            )\n        setattr(self._tf_trackable, name, list(variables))","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/export/saved_model_export_archive.py#L207-L243","documentation":"Error \"Expected `variables` to be a list/tuple/set. Received instead object of type '{type(variables)}'.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/export/saved_model_export_archive.py:225 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"}