Error2 reports
Fix UnboundLocalError
in HuggingFace Hub
✅ Solution
The "UnboundLocalError" occurs when a local variable is referenced before it has been assigned a value within its scope, often in conditional blocks. To fix it, ensure the variable is always assigned a default value (e.g., `metadata = None`) before the conditional block where it might be used, guaranteeing it's initialized regardless of the execution path. This prevents the error if the specific condition that would have originally assigned the value is not met.
Related Issues
Real GitHub issues where developers encountered this error:
Timeline
First reported:May 25, 2025
Last reported:Dec 10, 2025
Need More Help?
View the full changelog and migration guides for HuggingFace Hub
View HuggingFace Hub Changelog