"errorMessage": "Cannot convert undefined or null to object",
{
"errorType": "TypeError",
"errorMessage": "Cannot convert undefined or null to object",
"trace": [
"TypeError: Cannot convert undefined or null to object",
" at Function.entries (<anonymous>)",
" at module.exports (/var/task/node_modules/lowercase-keys/index.js:5:36)",
" at lambdaFunction (/var/task/node_modules/@probot/adapter-aws-lambda-serverless/lambda-function.js:19:28)",
" at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"
]
}
My probot lambda function is having issue above.
Can you please share some code demonstrating your issue?
I'm struggling with the same, I have the following.
Source
import { Probot } from "probot";
import { createLambdaFunction, createProbot } from "@probot/adapter-aws-lambda-serverless";
const app = (app: Probot) => {
app.log.info("TODO");
};
export const handler = async (event: any, context: any) => {
return createLambdaFunction(app, { probot: createProbot() })(event, context);
};
Bundling
npx esbuild src/index.ts --bundle --format=cjs --platform=node --target=node20 --outfile=dist/index.js --external:aws-sdk
package.json
{
"name": "todo",
"version": "1.0.0",
"private": true,
"description": "TODO",
"author": "TODO",
"license": "ISC",
"homepage": "https://github.com/",
"keywords": [
"probot",
"github",
"probot-app"
],
"scripts": {
"build": "tsc",
"start": "probot run ./lib/index.js",
"test": "vitest",
"bundle": "npx esbuild src/index.ts --bundle --format=cjs --platform=node --target=node20 --outfile=dist/index.js --external:aws-sdk"
},
"dependencies": {
"@octokit/rest": "^21.1.1",
"@probot/adapter-aws-lambda-serverless": "^4.0.3",
"mentions-regex": "^2.0.3",
"parse-commit-message": "^5.0.4",
"probot": "^13.0.1"
},
"devDependencies": {
"@types/node": "^20.0.0",
"esbuild": "^0.25.2",
"nock": "^14.0.0-beta.5",
"smee-client": "^2.0.0",
"typescript": "^5.3.3",
"vitest": "^3.1.1"
},
"engines": {
"node": ">= 18"
},
"type": "module"
}
I made some progress in my investigation. So, what I was trying to do:
- Create lambda function on AWS UI with Function URL that requires no authentication
- Upload the bundled probot JS code via the UI
- Go to the Test tab and run a test to see what happens
However, then payload sent to the lambda function during the test was not an HTTP event but an example object. I switched the test payload to the API Gateway HTTP API template which is an object that had the HTTP headers (expected by the lambda-function) so I got a different but reasonably expected error:
Snippet:
{
"errorType": "AggregateError",
"errorMessage": "\n Error: [@octokit/webhooks] signature does not match event payload and secret\n at verifyAndReceive
...
So, so far my conclusion is that I may be able to work may way through and get it working. But, from the adapter-aws-lambda-serverless lib perspective, better documentation and more importantly, better error handling and meaningful error messages would greatly improve the developer experience.