sst.dev icon indicating copy to clipboard operation
sst.dev copied to clipboard

Inconsistencies with TableName environment variable

Open pflugs30 opened this issue 2 years ago • 0 comments

I've been following the tutorial, and I've made it to the Logic Errors in Lambda Functions chapter. As I copied the first faulty code and tested it, I realized I was getting errors but not exactly as the tutorial indicated. On the next chapter, Unexpected Errors in Lambda Functions, I copied that code, too. I didn't receive the Lambda Timeout Error. Rather, I received this error:

MissingRequiredParameter: Missing required key 'TableName' in params
    at ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)
    at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:61:14)
    at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:88:21)
    at ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:34:10)
    at Request.VALIDATE_PARAMETERS (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:132:42)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at callNextListener (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
    at /var/runtime/node_modules/aws-sdk/lib/event_listeners.js:86:9
    at finish (/var/runtime/node_modules/aws-sdk/lib/config.js:396:7)
    at /var/runtime/node_modules/aws-sdk/lib/config.js:414:9 {
  code: 'MissingRequiredParameter',
  time: 2022-04-01T19:18:29.196Z
}

It took me a long time to realize what was wrong. In earlier chapters, the TableName parameter loaded its value from the process.env.TABLE_NAME environment variable. See this chapter for an example. Starting in this chapter, however, the environment variable becomes camel case (process.env.tableName). In all, there are 9 references process.env.TABLE_NAME and 51 references of process.env.tableName.

It seems logical to consolidate the references to one casing or the other. I'd be willing to make the change and submit a pull request, but I wanted to check with the team first. Thanks again for a great tutorial!

pflugs30 avatar Apr 01 '22 21:04 pflugs30