Skip to content

"errorMessage": "Cannot convert undefined or null to object", #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Neferpitooou opened this issue Jul 2, 2024 · 3 comments
Open

"errorMessage": "Cannot convert undefined or null to object", #129

Neferpitooou opened this issue Jul 2, 2024 · 3 comments

Comments

@Neferpitooou
Copy link

Neferpitooou commented Jul 2, 2024

{
  "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.

@wolfy1339
Copy link

Can you please share some code demonstrating your issue?

@ad-zsolt-imre
Copy link

ad-zsolt-imre commented Apr 8, 2025

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"
}

@ad-zsolt-imre
Copy link

I made some progress in my investigation. So, what I was trying to do:

  1. Create lambda function on AWS UI with Function URL that requires no authentication
  2. Upload the bundled probot JS code via the UI
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants