Custom App Error: Image S3 URL to Base64 conversion fails in Serverless Event (Status 500)

Hi community,

I am developing a printing solutions app (knowledge base) that requires converting an image S3 URL into a Base64 string.

The conversion logic works perfectly in my local development environment. However, after publishing it as a custom app, it fails during production execution. The conversion function is running inside a serverless event, and it throws the following error:

  • errorSource: "APP"

  • message: "Error while executing the app server script."

  • status: 500

It seems like an issue specific to the serverless execution environment. I suspect it might be due to network restrictions blocking the outbound S3 request, timeout limits, or how binary data/buffers are handled in this specific serverless environment compared to local Node.js.

Has anyone encountered this issue before, or does anyone know why this conversion script crashes the serverless event?

Any guidance or robust code snippets for handling S3-to-Base64 conversion in a serverless environment would be highly appreciated!

Thanks in advance!

Hi @Krishna_M,

This error occurs because standard Node.js networking libraries or file-handling modules (like fs or native binary buffers) are restricted within the production serverless environment.

To resolve this, please ensure the following:

  • Use Request Templates: The image from the S3 URL must be fetched using the platform’s standard Request Method/Templates rather than native Node libraries (like axios or http).

  • Response Type: Ensure the request template correctly handles image binary data (e.g., by using appropriate headers or matching the response type to the image format).

  • Payload Size Limits: Keep in mind that serverless execution has strict memory and payload limits. If the image is too large, converting it to a heavy Base64 string can cause the serverless script to crash.

If you are already using Request Templates, please share the code snippet of your conversion function so we can look for specific environment compatibility issues.

Best,

Himanshu