extensions icon indicating copy to clipboard operation
extensions copied to clipboard

🐛 [storage-resize-images] Console error when trying to use the extension

Open mehmet2006 opened this issue 1 year ago • 1 comments

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs for a specific extension in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • To file a bug against the Firebase Extensions platform, or for an issue affecting multiple extensions, please reach out to Firebase support directly.

[REQUIRED] Step 2: Describe your configuration

  • Extension name: storage-resize-images (storage-resize-images, firestore-send-email, etc)
  • Extension version: 0.2.5
  • Configuration values (redact info where appropriate):
    • Sharp constructor options for resizing images (Optional) { "position": “centre”, "fit": "inside" }
    • _

[REQUIRED] Step 3: Describe the problem

When I add this configuration, extension doesn't work Sharp constructor options for resizing images (Optional) { "position": “centre”, "fit": "inside" }

Steps to reproduce:

1- Install the extension 2- Add "position": “centre”, "fit": "inside" } to the field "Sharp constructor options for resizing images (Optional)" 3- Save 4- Upload image

What happened? How can we make the problem occur? cloudfunctions.googleapis.com

…loudFunctionsService.UpdateFunction

…orage-resize-images-generateResizedImage Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided module can't be loaded. Is there a syntax error in your code? Detailed stack trace: SyntaxError: Unexpected token “ in JSON at position 14 at JSON.parse () at allowAnimated (/workspace/lib/config.js:39:22) at Object. (/workspace/lib/config.js:60:15) at Module._compile (node:internal/modules/cjs/loader:1364:14) at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) at Module.load (node:internal/modules/cjs/loader:1203:32) at Module._load (node:internal/modules/cjs/loader:1019:12) at Module.require (node:internal/modules/cjs/loader:1231:19) at require (node:internal/modules/helpers:177:18) at Object. (/workspace/lib/resize-image.js:9:18) Could not load the function, shutting down.. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.

Expected result

It should resize the images

Actual result

It throws an error

mehmet2006 avatar May 31 '24 08:05 mehmet2006

I still get the same problem, though error code is slightly different Detailed stack trace: SyntaxError: Unexpected token “ in JSON at position 40

I tried to uninstall and reinstall but then i think it gets confused because of same name files.

EDIT : Even when deleting the resized files, it still throws the error

bertrandgelinas avatar Jul 10 '24 23:07 bertrandgelinas

Hi @mehmet2006, @bertrandgelinas

Thanks for raising this issue, we're reviewing it and will provide updates as soon as possible!

cabljac avatar Feb 11 '25 15:02 cabljac

Hi there,

it seems the source of the JSON parsing error is your use of "curly" or "typographic" double quotation marks in your config:

{ "position": “centre”, "fit": "inside" }

“centre”

Please use the standard straight double quotation marks "

like this:

{ "position": "centre", "fit": "inside" }

JSON officially only supports straight quotes (U+0022)

I'm going to close this as complete, feel free to reopen if the issue persists after using striaght quotation marks.

cabljac avatar Feb 12 '25 11:02 cabljac