{"record":{"id":"e2deaa5d2d0db787","repo":"lancedb/lancedb","slug":"unknown-table-pickle-state-kind-kind","errorCode":null,"errorMessage":"Unknown table pickle state kind: {kind}","messagePattern":"Unknown table pickle state kind: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/python/lancedb/permutation.py","lineNumber":414,"sourceCode":"    metadata = dict(permutation_data.schema.metadata or {})\n    if metadata.pop(b\"base_version\", None) is None:\n        return permutation_data\n    metadata.pop(b\"base_branch\", None)\n    return permutation_data.replace_schema_metadata(metadata)\n\n\ndef _table_from_pickle_state(state: dict[str, Any]) -> Table:\n    from . import connect\n\n    kind = state[\"kind\"]\n    if kind == \"remote\":\n        return state[\"table\"]\n    if kind == \"memory\":\n        return connect(\"memory://\").create_table(state[\"name\"], state[\"data\"])\n    if kind == \"local\":\n        db = connect(state[\"uri\"], storage_options=state[\"storage_options\"])\n        return db.open_table(state[\"name\"], namespace_path=state[\"namespace\"] or None)\n    raise ValueError(f\"Unknown table pickle state kind: {kind}\")\n\n\nclass Permutation:\n    \"\"\"\n    A Permutation is a view of a dataset that can be used as input to model training\n    and evaluation.\n\n    A Permutation fulfills the pytorch Dataset contract and is loosely modeled after the\n    huggingface Dataset so it should be easy to use with existing code.\n\n    A permutation is not a \"materialized view\" or copy of the underlying data.  It is\n    calculated on the fly from the base table.  As a result, it is truly \"lazy\" and does\n    not require materializing the entire dataset in memory.\n    \"\"\"\n\n    def __init__(\n        self,\n        base_table: Table,","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/python/python/lancedb/permutation.py#L396-L432","documentation":"Raised by _table_from_pickle_state (used by Permutation.__setstate__) when the deserialized state's 'kind' field is not one of 'remote', 'memory', or 'local'. This indicates the pickle payload was not produced by a recognized version of _table_to_pickle_state.","triggerScenarios":"Unpickling a Permutation whose state dict has an unrecognized or corrupted kind value; unpickling data produced by an incompatible library version or a hand-crafted state dict.","commonSituations":"Pickling with a patched/forked version of lancedb and unpickling with stock lancedb; manually editing pickle state; version drift between training and serving environments.","solutions":["Regenerate the pickle with the same lancedb version that created it (align versions across environments).","Ensure the Permutation was serialized via __getstate__ of a matching lancedb release, not manually constructed state.","If you cannot regenerate, reconstruct the Permutation from the table directly instead of unpickling."],"exampleFix":"// before\nperm = pickle.load(open(\"perm.pkl\", \"rb\"))  # pickled by forked lancedb\n// after\n# pip install 'lancedb==<same version as producer>'\nperm = pickle.load(open(\"perm.pkl\", \"rb\"))","handlingStrategy":"try-catch","validationCode":"state = pickle.loads(raw) if isinstance(raw, dict) else None\nif isinstance(state, dict) and state.get(\"kind\") not in {\"remote\", \"memory\", \"local\"}:\n    raise ValueError(f\"pickle produced by incompatible lancedb version: kind={state.get('kind')!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    perm = pickle.load(f)\nexcept ValueError as e:\n    if \"Unknown table pickle state kind\" in str(e):\n        raise RuntimeError(\"Pickle written by incompatible lancedb version; align versions and regenerate\") from e\n    raise","preventionTips":["Pin the same lancedb version in all environments that share pickled Permutations.","Never hand-edit pickle state dicts.","Prefer rebuilding Permutations from tables over transporting pickles across versions."],"tags":["permutation","pickle","deserialization","python"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"c7b051aff7039333a3f61b79217246c27676806a","analyzedAt":"2026-09-08T23:42:37.579Z","contentChangedAt":"2026-09-08T23:42:37.579Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}