Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): do not process faces of deleted assets #6710

Merged
merged 4 commits into from
Jan 29, 2024

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Jan 28, 2024

Description

When querying for faces during recognition, a face from an asset that was deleted after queueing will throw an error. While TypeORM has a default filter for deleted entities, it still returns an entity if it has deleted relations. The quick fix is to check the asset relation. Moving forward, it may be good to switch to inner joins for relations. This is beyond the scope of this fix as it involves switching to query builders, complicates custom selects, etc.

Fixes #6709

Copy link

cloudflare-workers-and-pages bot commented Jan 28, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 754a03e
Status:⚡️  Build in progress...

View logs

@mertalev mertalev changed the title fix(server): do not queue deleted assets fix(server): do not queue assets without an owner Jan 28, 2024
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

@jrasm91
Copy link
Contributor

jrasm91 commented Jan 28, 2024

It sounds like this is probably caused by trashed assets. So we should probably just make sure we ignore deleted assets instead.

@mertalev
Copy link
Contributor Author

That was the original PR, but then I noticed that there actually is a AND ("AssetEntity"."deletedAt" IS NULL) at the end of the query. So the issue is specific to ownerId

@mertalev
Copy link
Contributor Author

mertalev commented Jan 28, 2024

Although I'm not sure why a row still exists if ownerId is null.

@jrasm91
Copy link
Contributor

jrasm91 commented Jan 28, 2024

Right, I think it would be good to reproduce the actual issue before making a change like this.

I have seen owner being null before, specifically when something references a relation that has been deleted.

@mertalev mertalev force-pushed the fix/server-ignore-deleted branch from 21bed63 to ff7c6eb Compare January 28, 2024 23:58
@mertalev mertalev changed the title fix(server): do not queue assets without an owner fix(server): do not process faces of deleted assets Jan 28, 2024
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Can you add a unit test for this still working with deleted assets?

@mertalev mertalev enabled auto-merge (squash) January 29, 2024 00:30
@mertalev mertalev merged commit 0770ad1 into main Jan 29, 2024
23 of 24 checks passed
@mertalev mertalev deleted the fix/server-ignore-deleted branch January 29, 2024 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with facial recognition of deleted images
2 participants