{"record":{"id":"47262abe9f2aff71","repo":"huggingface/transformers","slug":"export-config-must-extend-exportconfigmixin","errorCode":null,"errorMessage":"Export config must extend ExportConfigMixin","messagePattern":"Export config must extend ExportConfigMixin","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/transformers/exporters/auto.py","lineNumber":177,"sourceCode":"\ndef register_exporter(name: str):\n    def register_exporter_fn(cls):\n        if name in AUTO_EXPORTER_MAPPING:\n            logger.warning(f\"Exporter '{name}' is already registered and will be overwritten.\")\n        if not issubclass(cls, HfExporter):\n            raise TypeError(\"Exporter must extend HfExporter\")\n        AUTO_EXPORTER_MAPPING[name] = cls\n        return cls\n\n    return register_exporter_fn\n\n\ndef register_export_config(name: str):\n    def register_export_config_fn(cls):\n        if name in AUTO_EXPORT_CONFIG_MAPPING:\n            logger.warning(f\"Export config '{name}' is already registered and will be overwritten.\")\n        if not issubclass(cls, ExportConfigMixin):\n            raise TypeError(\"Export config must extend ExportConfigMixin\")\n        AUTO_EXPORT_CONFIG_MAPPING[name] = cls\n        return cls\n\n    return register_export_config_fn\n\n\ndef get_hf_exporter(export_config) -> HfExporter:\n    return AutoHfExporter.from_config(export_config)\n","sourceCodeStart":159,"sourceCodeEnd":186,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/exporters/auto.py#L159-L186","documentation":"The @register_export_config(name) decorator raises TypeError when the decorated class is not a subclass of ExportConfigMixin. Config classes in the AUTO_EXPORT_CONFIG_MAPPING must support to_dict()/from_dict() round-tripping, which the mixin provides; registering a bare class would break AutoExportConfig.from_dict.","triggerScenarios":"Applying @register_export_config(\"mybackend\") to a plain dataclass or dict-like class that does not inherit ExportConfigMixin.","commonSituations":"Adding a custom backend alongside a custom exporter and forgetting the config half; subclassing one of the existing config classes (e.g. OnnxConfig) — note OnnxConfig already inherits the mixin, so this only fires for from-scratch classes.","solutions":["Inherit from ExportConfigMixin (directly or via an existing config class) before registering.","Set the class attribute export_format so to_dict() emits the registry name.","Verify with issubclass(cls, ExportConfigMixin) in a test."],"exampleFix":"# before\n@register_export_config(\"trt\")\n@dataclass\nclass TrtConfig:  # TypeError\n    precision: str = \"fp16\"\n\n# after\nfrom transformers.exporters.configs import ExportConfigMixin\n\n@register_export_config(\"trt\")\n@dataclass\nclass TrtConfig(ExportConfigMixin):\n    export_format = \"trt\"\n    precision: str = \"fp16\"","handlingStrategy":"type-guard","validationCode":"from transformers.exporters.configs import ExportConfigMixin\n\nassert issubclass(MyConfig, ExportConfigMixin), \"export configs must subclass ExportConfigMixin\"\nregister_export_config(\"mybackend\")(MyConfig)","typeGuard":"def is_valid_export_config(cls) -> bool:\n    from transformers.exporters.configs import ExportConfigMixin\n    return isinstance(cls, type) and issubclass(cls, ExportConfigMixin)","tryCatchPattern":null,"preventionTips":["Subclass an existing config (OnnxConfig/DynamoConfig/ExecutorchConfig) — they already carry the mixin","Set the export_format attribute on the config class so round-tripping works"],"tags":["export","registry","plugin","type-error"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}