Skip to content

fix(storage-resize-images): kit/extension parity – invalid IMG_SIZES or SHARP_OPTIONS deploy, then every upload fails #3265

Closed

Description

@IzaakGough

storage-resize-images kit/extension parity. Priority: high. A bad value deploys cleanly, then every upload fails without an error-level log.

Difference

  • Extension: IMG_SIZES and SHARP_OPTIONS are validated at install, and a value that passes the pattern but isn't valid JSON fails when the function loads.
  • Kit: the patterns apply only to the install prompt. A value already in .env is not checked at deploy, and SHARP_OPTIONS is first parsed on the first upload.

Reproduced

.env value Extension Kit
IMG_SIZES=200x (also x200, abc) Rejected: Invalid sizes, must be a comma-separated list of WIDTHxHEIGHT values. Deploy complete!; every upload logs Error when resizing image Error: Expected positive integer between 1 and 100000000 for height but received NaN and writes nothing
SHARP_OPTIONS={bad} Instance goes to ERRORED: Could not load the function Deploys; every upload is dropped with an unlabelled SyntaxError that doesn't name the param
SHARP_OPTIONS={"fit":"contain","background":"#ff0000"} (unquoted) Rejected: Please provide a valid JSON object. The .env parser cuts the value at #, so {"fit":"contain","background":" deploys and every upload is dropped as above

Quoting the value (SHARP_OPTIONS='{...}') deploys it in full and works. The README doesn't say to quote JSON values.

Code

Resolution

Validate IMG_SIZES, SHARP_OPTIONS and OUTPUT_OPTIONS at load, as validatePathListsFromEnv() does, so a bad value fails the deploy naming the param. In the README, say to quote JSON values in .env.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions