Skip to content

fix: images that fail content filter are added to failed directory#2780

Open
IzaakGough wants to merge 7 commits intonextfrom
fixcontentfilt
Open

fix: images that fail content filter are added to failed directory#2780
IzaakGough wants to merge 7 commits intonextfrom
fixcontentfilt

Conversation

@IzaakGough
Copy link
Copy Markdown
Contributor

Fixes #2762 and refactors content filtering functionality.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the image moderation and placeholder replacement logic, introducing a new placeholder module and updating the main handler. Several critical issues were identified: a regression prevents resized placeholders from being generated when an image is blocked, and the original blocked image is overwritten by the placeholder before it can be moved to the failed directory for review. Additionally, the content filter logic should be optimized by moving initialization and file reading outside the retry loop, and event metadata should correctly report the filter status.

Comment thread storage-resize-images/functions/src/index.ts Outdated
Comment thread storage-resize-images/functions/src/index.ts
Comment thread storage-resize-images/functions/src/content-filter.ts Outdated
Comment thread storage-resize-images/functions/src/index.ts Outdated
@IzaakGough IzaakGough requested a review from cabljac April 20, 2026 08:24
@cabljac cabljac marked this pull request as ready for review April 21, 2026 15:40
category,
threshold: filterLevel,
}));
})) as any;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not a fan of as any escape hatch here, can we fix

const HARM_CATEGORIES = [
"HARM_CATEGORY_HATE_SPEECH",
"HARM_CATEGORY_DANGEROUS_CONTENT",
"HARM_CATEGORY_UNSPECIFIED",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this was an actual category from the API, we should double check we're OK to remove this

}
: undefined;

// Determine max tokens based on whether we're using custom prompt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's not remove this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [storage-resize-images] Blocked images by Vertex AI are not moved to the failed path due to bypassed catch block

2 participants