{"record":{"id":"b213d14e92135baf","repo":"huggingface/transformers","slug":"auto-class-is-not-a-valid-auto-class-b213d1","errorCode":null,"errorMessage":"{auto_class} is not a valid auto class.","messagePattern":"(.+?) is not a valid auto class\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/feature_extraction_utils.py","lineNumber":663,"sourceCode":"    @classmethod\n    def register_for_auto_class(cls, auto_class=\"AutoFeatureExtractor\"):\n        \"\"\"\n        Register this class with a given auto class. This should only be used for custom feature extractors as the ones\n        in the library are already mapped with `AutoFeatureExtractor`.\n\n\n\n        Args:\n            auto_class (`str` or `type`, *optional*, defaults to `\"AutoFeatureExtractor\"`):\n                The auto class to register this new feature extractor with.\n        \"\"\"\n        if not isinstance(auto_class, str):\n            auto_class = auto_class.__name__\n\n        import transformers.models.auto as auto_module\n\n        if not hasattr(auto_module, auto_class):\n            raise ValueError(f\"{auto_class} is not a valid auto class.\")\n\n        cls._auto_class = auto_class\n\n\nFeatureExtractionMixin.push_to_hub = copy_func(FeatureExtractionMixin.push_to_hub)\nif FeatureExtractionMixin.push_to_hub.__doc__ is not None:\n    FeatureExtractionMixin.push_to_hub.__doc__ = FeatureExtractionMixin.push_to_hub.__doc__.format(\n        object=\"feature extractor\", object_class=\"AutoFeatureExtractor\", object_files=\"feature extractor file\"\n    )\n","sourceCodeStart":645,"sourceCodeEnd":673,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/feature_extraction_utils.py#L645-L673","documentation":"FeatureExtractionMixin.register_auto_class refuses an auto_class string that does not name an attribute of transformers.models.auto. Only real auto classes (e.g. 'AutoFeatureExtractor') can be attached so AutoFeatureExtractor can discover the custom feature extractor at runtime.","triggerScenarios":"Calling my_feature_extractor.register_auto_class('AutoFeatureExctrator') (typo), passing a custom class name not defined in transformers.models.auto, or passing a class object whose __name__ does not exist in the auto module.","commonSituations":"Typos in the class name, copy-pasting old examples that reference removed auto classes, or assuming any user-defined auto class works without it being exported from transformers.models.auto.","solutions":["Use exactly 'AutoFeatureExtractor' (the only supported auto class for feature extractors)","Check hasattr(transformers.models.auto, name) before registering if the name comes from user input","Update/downgrade transformers if the example you follow targets a different auto-class set"],"exampleFix":"# before\nfe.register_auto_class(\"AutoFeatureExctrator\")  # typo\n# after\nfe.register_auto_class(\"AutoFeatureExtractor\")","handlingStrategy":"validation","validationCode":"import transformers.models.auto as auto_module\n\ndef is_valid_auto_class(name: str) -> bool:\n    return hasattr(auto_module, name)","typeGuard":null,"tryCatchPattern":"try:\n    fe.register_auto_class(auto_class)\nexcept ValueError:\n    logging.warning(\"unsupported auto class %r; defaulting to AutoFeatureExtractor\", auto_class)\n    fe.register_auto_class(\"AutoFeatureExtractor\")","preventionTips":["Hardcode the literal 'AutoFeatureExtractor' rather than deriving names dynamically","Add a unit test asserting register_auto_class succeeds for your custom extractor"],"tags":["python","transformers","feature-extractor","auto-class","validation"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}