Skip to content

Unable to open file(s) uploaded as a zip file of a lambda function

0

I have uploaded the zip file of a lambda function. After uploading, the functions work fine, but the individual files (like lambda_function.py, ... etc) cannot be opened for viewing in the editor.

Get the following error: "Uanble to read file vfs:/.... (Error End of data reached (data length= 964, asked index = 958). Corrupted zip file ?

![Error Image] (/media/postImages/original/IMrtBSlTPLQ7yRT1Ts3Hlm4g)

asked 10 months ago3K views
3 Answers
1

Try switching to the old lambda console code editor. I have seen this too with the newer VSCode Editor

EXPERT
answered 10 months ago
  • Thank you. This answer solved my problem. The old code editor can open the files. new editor can't. But the old editor will stop service from 2025/1/31. hope AWS can solve it.

1

The issue you're experiencing with being unable to open individual files in the Lambda console editor after uploading a .zip file is likely due to a problem with the .zip file itself or how it was created. Here are a few things to check and try:

  1. Ensure that your .zip file is not corrupted. Try unzipping it on your local machine to verify its integrity.

  2. Make sure the files are at the root level of the .zip archive. Lambda expects the function code (e.g., lambda_function.py) to be at the root, not inside a folder within the .zip.

  3. Check the file permissions. Lambda requires 644 permissions for non-executable files and 755 for directories and executable files.

  4. Try recreating the .zip file using a different compression tool or method. Some compression methods may not be compatible with Lambda's unzipping process.

  5. If you're using dependencies, ensure they're properly included in the .zip file. For Python, for example, install dependencies in a separate directory and include them in the root of the .zip along with your function code.

  6. Verify that the total size of your unzipped deployment package doesn't exceed the Lambda limit of 250 MB.

If the problem persists after trying these steps, you might want to try uploading your code directly through the Lambda console's built-in editor (if your package is small enough) or use alternative deployment methods like AWS CLI or AWS SAM.

Remember, even if you can't view the files in the console editor, as long as your function is working correctly, the code is still being executed properly by Lambda.
Sources
Working with .zip file archives for Python Lambda functions - AWS Lambda
Deploy Node.js Lambda functions with .zip file archives - AWS Lambda
Deploying Lambda functions as .zip file archives - AWS Lambda

answered 10 months ago
EXPERT
reviewed 10 months ago
0

Try using a different ZIP tool. I get the same error when using Windows 11 build in ZIP. But when I use 7Zip, the uploaded ZIP file works fine with the new editor

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.