{"record":{"id":"0bfc371d977b2c08","repo":"cocoindex-io/cocoindex","slug":"record-type-must-be-a-record-type-got-type-recor","errorCode":null,"errorMessage":"record_type must be a record type, got {type(record_type)}","messagePattern":"record_type must be a record type, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/doris/_target.py","lineNumber":370,"sourceCode":"        self.primary_key = primary_key\n        self.row_type = row_type\n        for pk in self.primary_key:\n            if pk not in self.columns:\n                raise ValueError(\n                    f\"PK column '{pk}' not in columns: {list(self.columns.keys())}\"\n                )\n\n    @classmethod\n    async def from_class(\n        cls,\n        record_type: type[RowT],\n        primary_key: list[str],\n        *,\n        column_overrides: dict[str, DorisType | res_schema.VectorSchemaProvider]\n        | None = None,\n    ) -> \"TableSchema[RowT]\":\n        if not is_record_type(record_type):\n            raise TypeError(\n                f\"record_type must be a record type, got {type(record_type)}\"\n            )\n        columns = await cls._columns_from_record_type(record_type, column_overrides)\n        return cls(columns, primary_key, row_type=record_type)\n\n    @staticmethod\n    async def _columns_from_record_type(\n        record_type: type,\n        column_overrides: dict[str, DorisType | res_schema.VectorSchemaProvider] | None,\n    ) -> dict[str, ColumnDef]:\n        record_info = RecordType(record_type)\n        columns: dict[str, ColumnDef] = {}\n\n        for f in record_info.fields:\n            override = column_overrides.get(f.name) if column_overrides else None\n            type_info = analyze_type_info(f.type_hint)\n\n            all_annotations = []","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/doris/_target.py#L352-L388","documentation":"DorisTableSchema.from_class requires the record_type argument to be a cocoindex record type (verified by is_record_type). Any other object (plain dict, dataclass not registered, None) cannot be introspected into columns, so a TypeError is raised.","triggerScenarios":"Passing a plain Python class, dataclass, dict, or an instance instead of a cocoindex record type to DorisTableSchema.from_class(record_type=..., primary_key=[...]).","commonSituations":"Migrating from plain dataclasses/pydantic models without registering them as cocoindex record types; accidentally passing the instantiated record (an instance) rather than the type.","solutions":["Pass a cocoindex record type (one built with cocoindex's schema record mechanism) as record_type","If you have a plain dataclass, convert/declare it as a cocoindex record type first","Ensure you pass the class/type itself, not an instance"],"exampleFix":"// before\nawait DorisTableSchema.from_class(MyDataclass, primary_key=[\"id\"])\n// after\nawait DorisTableSchema.from_class(coco_record_type, primary_key=[\"id\"])","handlingStrategy":"type-guard","validationCode":"from cocoindex.resources import schema as _schema\nassert _schema.is_record_type(record_type)","typeGuard":"def is_valid_record_type(rt: object) -> bool:\n    from cocoindex.resources import schema as _schema\n    return _schema.is_record_type(rt)","tryCatchPattern":"try:\n    schema = await DorisTableSchema.from_class(record_type, primary_key=pks)\nexcept TypeError as e:\n    raise ValueError(f\"Bad record_type: {e}\") from e","preventionTips":["Pass the cocoindex record type, not dataclasses or instances","Check is_record_type before calling from_class","Convert legacy dataclasses to cocoindex records once at startup"],"tags":["doris","type-mismatch","schema","argument"],"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"}