fix(storage-resize-images): a malformed model reply to CUSTOM_FILTER_PROMPT blocks the image (existing extension bug, also in the kit)

Aperta
#3,269 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
firebase, typescript
Ambito
ai, backend

Direzione di ricerca

Start with the two content-filter.ts files named in the issue: functions/src/content-filter.ts for the extension and kits/storage-resize-images/src/content-filter.ts for the kit. Trace how custom prompt replies are validated and how blocked results are logged, then read the nearby tests or run the relevant test commands. Done when a schema failure with a custom prompt is retryable and logged as a prompt error, while finishReason: "blocked" still follows the safety block path.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

kits type: bug

Affects the extension and the kit. Priority: medium. With CUSTOM_FILTER_PROMPT set, an image that should pass can be replaced by the placeholder, and the log blames the safety filters.

Problem

When the model's reply fails genkit's output schema check (must have required property 'response'), the code treats it as a block. One malformed reply turns a "no" into a placeholder, and the log says Image content blocked by Vertex AI content filters., which points the user at CONTENT_FILTER_LEVEL rather than the prompt. By reading, with DELETE_ORIGINAL_FILE=true a blocked image counts as a success, so the original is also deleted (not run).

Reproduced

CONTENT_FILTER_LEVEL=BLOCK_MEDIUM_AND_ABOVE, CUSTOM_FILTER_PROMPT="Does this image contain a cat?" and a custom placeholder. An image with no cat was uploaded three times to each side:

  • Kit: placeholder in 2 of 3 runs.
  • Extension: resized in 3 of 3 runs.

Direct calls with the extension's genkit version reproduced the schema failure on some replies. The moderation code is the same on both sides (by reading), so the split is put down to model nondeterminism.

Code
Resolution

With a custom prompt, treat a schema failure as a retryable error rather than a block, and log a message that names the custom prompt. Keep the safety-filter block (finishReason: "blocked") as it is.

Lingua principale
TypeScript
Stelle
979
Fork
436
Merge medio
2g 13h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/extensions

Tutte le issue di firebase/extensions

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.