Skip to content
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

"Fvr.isPlainObject is not a function" during constructor #519

Closed
benminer opened this issue Sep 20, 2022 · 1 comment · Fixed by octokit/request.js#651
Closed

"Fvr.isPlainObject is not a function" during constructor #519

benminer opened this issue Sep 20, 2022 · 1 comment · Fixed by octokit/request.js#651
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects

Comments

@benminer
Copy link

benminer commented Sep 20, 2022

What happened?
Using Octokit to handle GitHub webhook events, running in AWS Lambda. During the Octokit constructor, a type error is thrown from what I️ have gathered is a missing dependency "is-plain-object".

Node Version: 16.14.2 + TypeScript 4.7
Bundling using Esbuild 0.14.54

Not much to show here. It happens on import for me. My import statements:

import { createAppAuth } from '@octokit/auth-app'
import { Octokit } from 'octokit'

// Then used accordingly
    const octokit = new Octokit({
      authStrategy: createAppAuth,
      auth: {
        appId: config.github.appId,
        privateKey: pk,
        installationId
      }
    })
    const {
      data: { slug }
    } = await octokit.rest.apps.getAuthenticated()
   await octokit.rest.issues.create({
      title: 'New Pull Request',
      owner: repoOwner,
      repo: repoName,
      issue_number: prNumber
    })

But I️ don't even get into my webhook route handler, it crashes the runtime as soon as it loads.

What did you expect to happen?
For the dependency to be present and allow the package to load.

What the problem might be
Not sure, it seems that is-plain-object is marked as a peer dep in most Octokit libraries. I️ installed it myself as well, to no avail.

@benminer benminer added the Type: Bug Something isn't working as documented label Sep 20, 2022
@ghost ghost added this to Bugs in JS Sep 20, 2022
@gr2m gr2m added Type: Support Any questions, information, or general needs around the SDK or GitHub APIs and removed Type: Bug Something isn't working as documented labels Sep 20, 2022
@ghost ghost moved this from Bugs to Support in JS Sep 20, 2022
@gr2m
Copy link
Contributor

gr2m commented Sep 20, 2022

It sounds like a build error. I've seen people running into problems with is-plain-object before. It's not a peer dependency, it's a dependency of @octokit/request and @octokit/endpoint, so it's a sub-dependency of octokit.

The last release is 2 years old though: https://github.com/jonschlinkert/is-plain-object/releases

So I don't think it's a problem with Octokit, but rather with the way you build your code for lambda.

I'm pretty sure this will be resolved with https://github.com/octokit/octokit-next.js where we go all in on ESM, but for the time being folks run into problems like this, unfortunately. I hope you can figure it out, please share what worked for you when you do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
No open projects
JS
  
Support
Development

Successfully merging a pull request may close this issue.

2 participants