Fix legacy StableDiffusionPipeline init crash (#6969)#1
Conversation
…rgs (huggingface#6969) Skip library-tuple registration for scalar values in register_modules and __setattr__, and guard _fetch_class_library_tuple with TypeError. Adds fast regression tests for legacy positional super().__init__ signatures.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Scalar skips config key
- Changed the scalar branch in register_modules to register (None, None) in config like the None path, so config keys stay aligned with the init signature and .components no longer raises ValueError.
Or push these changes by commenting:
@cursor push 496169cb19
Preview (496169cb19)
diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py
--- a/src/diffusers/pipelines/pipeline_utils.py
+++ b/src/diffusers/pipelines/pipeline_utils.py
@@ -215,7 +215,7 @@
elif isinstance(module, (bool, int, float, str)):
# Scalar values (e.g. bool mis-passed as image_encoder from legacy super().__init__) are not
# model components — skip library tuple registration. See https://github.com/huggingface/diffusers/issues/6969
- register_dict = {}
+ register_dict = {name: (None, None)}
else:
library, class_name = _fetch_class_library_tuple(module)
register_dict = {name: (library, class_name)}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 69ee02e. Configure here.
| # save model index config | ||
| self.register_to_config(**register_dict) | ||
| if register_dict: | ||
| self.register_to_config(**register_dict) |
There was a problem hiding this comment.
Scalar skips config key
Medium Severity
When register_modules receives a scalar component (e.g. a bool mis-bound to image_encoder), it sets an empty register_dict and skips register_to_config, unlike None which records (None, None). The attribute is still set, but the config omits that module name. components builds keys from config and then requires they match the init signature, so legacy-init pipelines can raise ValueError after init succeeds.
Reviewed by Cursor Bugbot for commit 69ee02e. Configure here.



Eval r2 fix for huggingface#6969: scalar guard in register_modules, TypeError in _fetch_class_library_tuple, 4 fast tests green.
Made with Cursor