{"record":{"id":"bba64629555ae9db","repo":"cocoindex-io/cocoindex","slug":"row-row-id-r-schema-declares-a-single-unnamed-v","errorCode":null,"errorMessage":"Row {row.id!r}: schema declares a single unnamed vector but row.vector is a dict.","messagePattern":"Row (.+?): schema declares a single unnamed vector but row\\.vector is a dict\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/turbopuffer/_target.py","lineNumber":217,"sourceCode":"    out: dict[str, Any] = {\"id\": row.id}\n\n    if isinstance(schema.vectors, _ResolvedNamedVectorsDef):\n        vector_field_names = set(schema.vectors.vectors)\n        if not isinstance(row.vector, dict):\n            raise ValueError(\n                f\"Row {row.id!r}: schema declares named vectors \"\n                f\"({sorted(vector_field_names)}) but row.vector is not a dict.\"\n            )\n        missing = vector_field_names - set(row.vector)\n        if missing:\n            raise ValueError(\n                f\"Row {row.id!r}: missing vector fields {sorted(missing)}.\"\n            )\n        for name, vec in row.vector.items():\n            out[name] = _vector_to_list(vec)\n    else:\n        vector_field_names = {_DEFAULT_VECTOR_FIELD}\n        if isinstance(row.vector, dict):\n            raise ValueError(\n                f\"Row {row.id!r}: schema declares a single unnamed vector but \"\n                f\"row.vector is a dict.\"\n            )\n        out[_DEFAULT_VECTOR_FIELD] = _vector_to_list(row.vector)\n\n    reserved = {\"id\"} | vector_field_names\n    if row.attributes:\n        for k, v in row.attributes.items():\n            if k in reserved:\n                raise ValueError(f\"Row {row.id!r}: attribute name {k!r} is reserved.\")\n            out[k] = v\n\n    return out\n\n\ndef _vector_type_str(vs: res_schema.VectorSchema) -> str:\n    \"\"\"Render a VectorSchema as turbopuffer's ``[N]fXX`` type string.\"\"\"","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/turbopuffer/_target.py#L199-L235","documentation":"The inverse of error 240: when the turbopuffer namespace schema declares a single unnamed vector (a plain VectorDef), `row.vector` must be a single sequence of floats. If a dict is passed (the shape used for named vectors), `_row_to_upsert` raises this ValueError because there are no vector field names to key by.","triggerScenarios":"NamespaceSchema created with vectors=VectorDef(...) (unnamed single vector) but the row is built as Row(id=..., vector={\"vec\": [0.1, 0.2]}) or with a dict of multiple named embeddings, then passed to reconcile.","commonSituations":"Copying row-construction code from a named-vectors example into a single-vector namespace; switching a schema from named vectors back to a single vector without simplifying the rows; wrapping the embedding in a dict for 'clarity'.","solutions":["Pass the vector data directly as a sequence/ndarray: Row(id=..., vector=[0.1, 0.2]) with no dict wrapper.","If you need multiple vectors per row, change the schema to declare named vectors (a dict of VectorDefs) so dicts are accepted.","Extract the single embedding from the dict before constructing the Row."],"exampleFix":"// before\nRow(id=7, vector={\"embedding\": embed(text)})\n\n// after\nRow(id=7, vector=embed(text))","handlingStrategy":"type-guard","validationCode":"if not isinstance(schema.vectors, _ResolvedNamedVectorsDef) and isinstance(row.vector, dict):\n    raise TypeError(\"Single-vector schema: pass the vector directly, not a dict\")","typeGuard":"def is_plain_vector(v: object) -> TypeGuard[Sequence[float] | np.ndarray]:\n    return isinstance(v, (np.ndarray, (list, tuple))) and not isinstance(v, dict)","tryCatchPattern":"try:\n    await component.reconcile(row)\nexcept ValueError as e:\n    if \"row.vector is a dict\" in str(e):\n        (only,) = row.vector.values()\n        row = replace(row, vector=only)\n    else:\n        raise","preventionTips":["For single-vector schemas, pass embeddings straight from the encoder with no dict wrapper","Keep one Row factory per schema shape and document which is which","Type-annotate row.vector construction sites so mypy catches dict-vs-sequence slips"],"tags":["python","vector","schema-mismatch","turbopuffer"],"backgroundTag":"type-mismatch","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}