Spaces:
Running
Running
π Fix dictionary iteration bug in file processing
Browse files- Fixed 'dictionary changed size during iteration' error
- Create copy of photo items before iterating and modifying dictionary
- File uploads and signed URL generation now work without errors
The bug was occurring when adding *_url keys to photos dictionary while iterating over it.
- supabase_storage.py +3 -1
supabase_storage.py
CHANGED
@@ -131,7 +131,9 @@ class SupabaseFileStorage:
|
|
131 |
if processed_data.get('photographs'):
|
132 |
photos = processed_data['photographs']
|
133 |
if isinstance(photos, dict):
|
134 |
-
|
|
|
|
|
135 |
if file_path:
|
136 |
try:
|
137 |
photos[f"{category}_url"] = self.get_image_url(file_path)
|
|
|
131 |
if processed_data.get('photographs'):
|
132 |
photos = processed_data['photographs']
|
133 |
if isinstance(photos, dict):
|
134 |
+
# Create a copy of items to avoid dictionary size change during iteration
|
135 |
+
photo_items = list(photos.items())
|
136 |
+
for category, file_path in photo_items:
|
137 |
if file_path:
|
138 |
try:
|
139 |
photos[f"{category}_url"] = self.get_image_url(file_path)
|