Build Fails – Invalid AWS Lambda parameters?

Getting this error while pushing a new deploy. Never had this issue before and I am really perplexed about the error message.

What the console says:

7:32:23 AM: Function Dir: /opt/build/repo/src/functions
7:32:23 AM: TempDir: /tmp/zisi-5da6aad657a7ce9601ac89f4
7:32:24 AM: Prepping functions with zip-it-and-ship-it 0.3.1
7:34:06 AM: [ { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/create-user-ad.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path:
7:34:06 AM:      '/tmp/zisi-5da6aad657a7ce9601ac89f4/create-user-message-respond.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/create-user-message.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-ad.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-ads.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-category-ads.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path:
7:34:06 AM:      '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-conversation-messages.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-home-ads.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-user-ads.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path:
7:34:06 AM:      '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-user-conversation.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path:
7:34:06 AM:      '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-user-conversations.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path:
7:34:06 AM:      '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-user-notifications.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/fetch-user.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/logout.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/search-ads.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path: '/tmp/zisi-5da6aad657a7ce9601ac89f4/token.zip',
7:34:06 AM:     runtime: 'js' },
7:34:06 AM:   { path:
7:34:06 AM:      '/tmp/zisi-5da6aad657a7ce9601ac89f4/update-user-notifications.zip',
7:34:06 AM:     runtime: 'js' } ]
7:34:06 AM: Prepping functions complete
7:34:06 AM: Caching artifacts
7:34:06 AM: Started saving node modules
7:34:06 AM: Finished saving node modules
7:34:06 AM: Started saving yarn cache
7:34:06 AM: Finished saving yarn cache
7:34:06 AM: Started saving pip cache
7:34:06 AM: Finished saving pip cache
7:34:06 AM: Started saving emacs cask dependencies
7:34:06 AM: Finished saving emacs cask dependencies
7:34:06 AM: Started saving maven dependencies
7:34:06 AM: Finished saving maven dependencies
7:34:06 AM: Started saving boot dependencies
7:34:06 AM: Finished saving boot dependencies
7:34:06 AM: Started saving go dependencies
7:34:06 AM: Finished saving go dependencies
7:34:11 AM: Build script success
7:34:11 AM: Starting to deploy site from 'dist'
7:34:11 AM: Creating deploy tree 
7:34:11 AM: 0 new files to upload
7:34:11 AM: 17 new functions to upload
7:36:16 AM: Failed to upload file: &{Name:create-user-message-respond Sum:18066c9d6f6c2b03ed6a5266bcb83ad57e228eb48dfdd991aef36080ce52f3f3 Runtime:js Size:<nil> Path: Buffer:0xc0001a11a0}
7:36:16 AM: Failed to upload file: &{Name:fetch-home-ads Sum:0268001bba0330f0751469e0fe0e03aa25ca76591535a939904248cce6c7b6a8 Runtime:js Size:<nil> Path: Buffer:0xc0001a17d0}
7:36:22 AM: Failed to upload file: &{Name:fetch-user-ads Sum:25162720a7f9c11785786e91a8f21a160039a4e02bcce6a68c0bfde4f38a4ea0 Runtime:js Size:<nil> Path: Buffer:0xc0001a1860}
7:36:23 AM: Failed to upload file: &{Name:fetch-category-ads Sum:2eaf489b9504fa2974774672a7084ae27acade8a215b30769e0299e42a4a1b57 Runtime:js Size:<nil> Path: Buffer:0xc0001a1740}
7:36:27 AM: Failed to upload file: &{Name:fetch-conversation-messages Sum:50622dd3a5745daefa49a153ee91ceef4ac3dda115f49a4673fccf8cd69e47ca Runtime:js Size:<nil> Path: Buffer:0xc0001a1410}
7:36:28 AM: Failed to upload file: &{Name:fetch-ads Sum:a5b1f86dfefa4fb02608043d4d0ec8fe537426f6c48e3e28e1ffdc1ba7beb4b7 Runtime:js Size:<nil> Path: Buffer:0xc0001a13e0}
7:36:31 AM: Failed to upload file: &{Name:create-user-message Sum:5594ae4956a6bb5d73a15de6e9b88d189f82d8cf7bad12419182c9e7cdc4ca11 Runtime:js Size:<nil> Path: Buffer:0xc0001a1080}
7:36:33 AM: Failed to upload file: &{Name:create-user-ad Sum:efcaedf0f9d36ba363dd58abe58c3ae55f80612012727138a9626798a090350b Runtime:js Size:<nil> Path: Buffer:0xc0001a0f90}
7:36:49 AM: Failed to upload file: &{Name:fetch-user Sum:a4c09411a7595f45aba084fd37a17fe1788ae6957295ef7e8fca160a1c98b5ac Runtime:js Size:<nil> Path: Buffer:0xc0001a19e0}
7:36:59 AM: Failed to upload file: &{Name:fetch-ad Sum:0c4dd28236013d3eac8b35761ede21a68251a62a4f72bc2babc97cf08cd812ce Runtime:js Size:<nil> Path: Buffer:0xc0001a16b0}
7:36:59 AM: Failing build: Failed to deploy site
7:36:59 AM: failed during stage 'deploying site': Failed to execute deploy: Upload cancelled: fetch-ad
7:36:59 AM: Finished processing build request in 6m58.421920962s

Then I tried to deploy with the Netlify CLI, there the console says:

→ netlify deploy --dir=public --functions=./src/functions
Deploy path:        /Git/FOOBAR/public
Functions path:     /Git/FOOBAR/src/functions
Configuration path: /Git/FOOBAR/netlify.toml
Deploying to draft URL...
✔ Finished hashing 33 files and 17 functions
✔ CDN requesting 0 files and 17 functions
▮ (14/17) Uploading search-ads... ›   Warning: JSONHTTPError: undefined 422
 ›   Warning: 
 ›   {
 ›      "name": "JSONHTTPError",
 ›      "status": 422,
 ›      "json": {
 ›        "errors": {
 ›          "function_validation": "Invalid AWS Lambda parameters. Reserved keys used in this request",
 ›          "code": "InvalidParameterValueException"
 ›        }
 ›      }
 ›   }
 ›
JSONHTTPError: Unprocessable Entity
    at NetlifyAPI.uploadDeployFunction (~/.config/yarn/global/node_modules/netlify/src/open-api/index.js:162:15)
    at runMicrotasks (<anonymous>)

I checked my used env variables and double-checked with https://docs.aws.amazon.com/lambda/latest/dg/lambda-environment-variables.html – nothing identical here.

I retried the deploy with a clean cache – didn’t work.

I’ve removed the node_modules and yarn.lock file, rebuild everything locally – no problem.

I checked the size of my environment variables, but the biggest one has 3,136 bytes – so it should be ok.

I even removed all my functions, created the hello-world example with the Netlify-CLI – so it’s a standardized fresh function which must work – but still the same error.

So what might this be, even when a function without node dependencies fails? Thanks in advance for your suggestions!

Thanks to Chris McCraw from the Netlify Support Team I now know, that the restriction of the maximum size of environment variables concatenated all together (e.g. VAR1=val1,VAR2=val2) should not be bigger than 4,096 bytes.

So problem is solved!

1 Like

thanks for posting the solution! This is super helpful for other users - maybe if you see someone posting about the same issue, you can share your fixes with them :slight_smile: