4.4.0 S3 No Longer Working

Wappler Version : 4.4.0
Operating System : Mac OS Big Sur
Server Model: Node Js
Database Type: My Sql
Hosting Type: Docker

Expected behavior
S3 should still retrieve images

Actual behavior
After update I get this error

{
    "status": "500",
    "message": "s3.getSignedUrl is not a function",
    "stack": "TypeError: s3.getSignedUrl is not a function\n    at App.signDownloadUrl (/opt/node_app/lib/modules/s3.js:128:19)\n    at App._exec (/opt/node_app/lib/core/app.js:463:57)\n    at App._exec (/opt/node_app/lib/core/app.js:434:28)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\n    at async App.exec (/opt/node_app/lib/core/app.js:403:9)\n    at async App.define (/opt/node_app/lib/core/app.js:393:9)"
}

How to reproduce

Try a sign download url with s3 (im using digital ocean spaces)

I do also see this:

npm WARN @aws-sdk/middleware-sdk-s3@3.41.0 requires a peer of @aws-sdk/signature-v4-crt@^3.31.0 but none is installed. You must install peer dependencies yourself.

When installing the node packages

And when i create a new s3 as it looked like the module was missing as even upload won’t work I see this in the deploy log:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN @aws-sdk/middleware-sdk-s3@3.41.0 requires a peer of @aws-sdk/signature-v4-crt@^3.31.0 but none is installed. You must install peer dependencies yourself.

wasn’t sure If the aws-sdk one is related to help narrow the issue.

The signature-v4-crt package is not needed, it is needed for the S3 Multi-Region Access Point (MRAP) feature which we don’t support. It is registered in the package.json from the s3 sdk as a peer dependency, but is actually an optional dependency.

I will check the getSignedUrl function, the sdk was upgraded from v2 to v3, so there could be some incompatibility. Did you also update the files in the lib folder?

Thanks for the quick response,

I chose to update on every pop up that asks so I believe so can’t remember all the pop ups entirely.

It seems that on 4.4.1 the s3.getSignedUrl looks to be working but s3.upload is throwing the error still:

{
    "status": "500",
    "message": "s3.upload is not a function",
    "stack": "TypeError: s3.upload is not a function\n    at App.putFile (/opt/node_app/lib/modules/s3.js:70:19)\n    at App._exec (/opt/node_app/lib/core/app.js:463:57)\n    at App._exec (/opt/node_app/lib/core/app.js:434:28)\n    at async App.exec (/opt/node_app/lib/core/app.js:403:9)\n    at async App.repeat (/opt/node_app/lib/modules/core.js:72:17)\n    at async App._exec (/opt/node_app/lib/core/app.js:463:30)\n    at async App._exec (/opt/node_app/lib/core/app.js:434:17)\n    at async App.exec (/opt/node_app/lib/core/app.js:403:9)\n    at async App.define (/opt/node_app/lib/core/app.js:393:9)"
}

i’m experiencing the same issue in version 4.4.1 .

i’m using Nodejs and docker

Having issues as well in 4.4.1

status: "500", code: "MODULE_NOT_FOUND",…}
code: "MODULE_NOT_FOUND"
message: "Cannot find module 'aws-sdk'\nRequire stack:\n- /opt/node_app/lib/core/app.js\n- /opt/node_app/lib/core/middleware.js\n- /opt/node_app/lib/setup/routes.js\n- /opt/node_app/lib/server.js\n- /opt/node_app/index.js"
stack: "Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /opt/node_app/lib/core/app.js\n- /opt/node_app/lib/core/middleware.js\n- /opt/node_app/lib/setup/routes.js\n- /opt/node_app/lib/server.js\n- /opt/node_app/index.js\n    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)\n    at Function.Module._load (internal/modules/cjs/loader.js:725:27)\n    at Module.require (internal/modules/cjs/loader.js:952:19)\n    at require (internal/modules/cjs/helpers.js:88:18)\n    at App.setS3Provider (/opt/node_app/lib/core/app.js:295:21)\n    at App.getS3Provider (/opt/node_app/lib/core/app.js:320:25)\n    at App.putFile (/opt/node_app/lib/modules/s3.js:64:25)\n    at App._exec (/opt/node_app/lib/core/app.js:453:57)\n    at App._exec (/opt/node_app/lib/core/app.js:424:28)\n    at async App.exec (/opt/node_app/lib/core/app.js:393:9)"
status: "500"

When trying a ‘S3 put file’ with DO spaces. (Was previously working)

Seems like you have a mixture of old server connect files and new packages.

Try forcing update of all server connect files by deleting The “lib” folder in your root and then save a server connect action so it will be regenerated.

Make sure it is all well deployed to your live server afterwards.

Just tried deleting the lib and still getting the s3.upload error seems the s3.getSignedUrl is fine in 4.4.1 neither worked in 4.4.0

Deleted the lib, saved a server action.

New error: s3.upload is not a function - just like @Sorry_Duh

{status: "500", message: "s3.upload is not a function",…}
message: "s3.upload is not a function"
stack: "TypeError: s3.upload is not a function\n    at App.putFile (/opt/node_app/lib/modules/s3.js:70:19)\n    at App._exec (/opt/node_app/lib/core/app.js:463:57)\n    at App._exec (/opt/node_app/lib/core/app.js:434:28)\n    at async App.exec (/opt/node_app/lib/core/app.js:403:9)\n    at async App.exec (/opt/node_app/lib/modules/core.js:197:13)\n    at async App._exec (/opt/node_app/lib/core/app.js:463:30)\n    at async App._exec (/opt/node_app/lib/core/app.js:434:17)\n    at async App.exec (/opt/node_app/lib/core/app.js:403:9)\n    at async App.define (/opt/node_app/lib/core/app.js:393:9)"
status: "500"

Here an update that should fix the remaining issues. Unzip in lib/modules.

s3.zip (1.2 KB)

@patrick thanks, this fixed that error.

However, it suddenly creates a validation error. This is happening with a server action that was working before:

The error:

message: "Bucket name shouldn't contain '/', received 'smartclasses/school/2/course/3/lecture/3'"
stack: "InvalidBucketName: Bucket name shouldn't contain '/', received 'smartclasses/school/2/course/3/lecture/3'\n    at /opt/node_app/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/validate-bucket-name.js:9:25\n    at /opt/node_app/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:28\n    at S3.send (/opt/node_app/node_modules/@aws-sdk/smithy-client/dist-cjs/client.js:20:20)\n    at S3.putObject (/opt/node_app/node_modules/@aws-sdk/client-s3/dist-cjs/S3.js:1229:25)\n    at App.putFile (/opt/node_app/lib/modules/s3.js:70:19)\n    at App._exec (/opt/node_app/lib/core/app.js:463:57)\n    at App._exec (/opt/node_app/lib/core/app.js:434:28)\n    at async App.exec (/opt/node_app/lib/core/app.js:403:9)\n    at async App.define (/opt/node_app/lib/core/app.js:393:9)"
status: "500"

Perhaps the update changed something? How can I upload a file to certain folder in digital ocean spaces?

Edit (solution:)

Thanks you @sid.

The ‘putfile’ wappler UI is a bit confusing to me. This is how it should be:

We usually keep the bucket name to just say smartclass, and rest of the path goes into the key.
Make sure to NOT start the key with a /.
It could be that the way you were doing it earlier should not have been allowed.

1 Like

Thanks @sid, literally just closed this issue and parked it for later when I got your reply.
Let me try that, I thought they ‘key’ part was just for finding the file on the server - not for the space!

A similar problem occurred after the update. And I changed the existing s3.js file to the s3.js file attached by Patrick. After changing the file, it is uploaded well to s3 through ‘putfile’, but not through ‘sign upload url’.
When attempting to upload through ‘sign upload url’, 403 error occurs.

This has been fixed in Wappler 4.4.2

This topic was automatically closed after 47 hours. New replies are no longer allowed.