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.
-->
This commit is contained in:
Millun Atluri 2023-12-26 15:38:55 +11:00 committed by GitHub
commit 12f2357e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -167,6 +167,9 @@ class Migration2Callback:
except ImageFileNotFoundException:
self._logger.warning(f"Image {image_name} not found, skipping")
continue
except Exception as e:
self._logger.warning(f"Error while checking image {image_name}, skipping: {e}")
continue
if "invokeai_workflow" in pil_image.info:
try:
UnsafeWorkflowWithVersionValidator.validate_json(pil_image.info.get("invokeai_workflow", ""))