extensions icon indicating copy to clipboard operation
extensions copied to clipboard

storage-resize-images: prevent double trigger by honoring resizedImage flag (string or boolean)

Open cnaples79 opened this issue 3 months ago • 1 comments

The storage-resize-images function could run twice for a single upload if the resized outputs re-triggered the function. This happens when resizedImage custom metadata is stored as a boolean true while the filter only checked for the string "true".

Changes

  • filters: treat metadata.resizedImage === true or "true" as already-resized to short‑circuit early.
  • upload: set resizedImage metadata to string "true" for consistency with existing expectations.
  • tests: add coverage for the boolean variant in metadata checks.

Why

  • Cloud Storage custom metadata can arrive as a boolean or a string; handling both ensures idempotence and prevents reprocessing outputs.

Fixes #932.

cnaples79 avatar Sep 16 '25 12:09 cnaples79

Hi, thanks for opening this issue! I'm not sure it will fix #932 though, as the function will still be invoked? The filtering happens after the invocation within the runtime of the function. Making this more robust is still worthwhile though, we'll review this and hopefully get it out ASAP

cabljac avatar Sep 18 '25 08:09 cabljac