Skip to content

Commit 12f2357

Browse files
authored
feat(db): handle PIL errors opening images gracefully (#5314)
## What type of PR is this? (check all applicable) - [ ] Refactor - [ ] Feature - [x] Bug Fix - [ ] Optimization - [ ] Documentation Update - [ ] Community Node Submission ## Have you discussed this change with the InvokeAI team? - [x] Yes - [ ] No, because: ## Description For example, if PIL tries to open a *really* big image, it will raise an exception to prevent reading a huge object into memory. ## Related Tickets & Documents <!-- For pull requests that relate or close an issue, please include them below. For example having the text: "closes #1234" would connect the current pull request to issue 1234. And when we merge the pull request, Github will automatically close the issue. --> - https://discord.com/channels/1020123559063990373/1149513695567810630/1186200089149046804 ## QA Instructions, Screenshots, Recordings This should fix the error in the discord thread <!-- Please provide steps on how to test changes, any hardware or software specifications as well as any other pertinent information. --> ## Merge Plan Can be merged when @Millu confirms it fixes the issue he ran into <!-- A merge plan describes how this PR should be handled after it is approved. Example merge plans: - "This PR can be merged when approved" - "This must be squash-merged when approved" - "DO NOT MERGE - I will rebase and tidy commits before merging" - "#dev-chat on discord needs to be advised of this change when it is merged" A merge plan is particularly important for large PRs or PRs that touch the database in any way. -->
2 parents 5196e4b + 60629cb commit 12f2357

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

invokeai/app/services/shared/sqlite_migrator/migrations/migration_2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ def _migrate_embedded_workflows(self, cursor: sqlite3.Cursor) -> None:
167167
except ImageFileNotFoundException:
168168
self._logger.warning(f"Image {image_name} not found, skipping")
169169
continue
170+
except Exception as e:
171+
self._logger.warning(f"Error while checking image {image_name}, skipping: {e}")
172+
continue
170173
if "invokeai_workflow" in pil_image.info:
171174
try:
172175
UnsafeWorkflowWithVersionValidator.validate_json(pil_image.info.get("invokeai_workflow", ""))

0 commit comments

Comments
 (0)