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

TypeError: Cannot read property 'error' of undefined on POST #314

Open
jpenagg opened this issue Oct 18, 2022 · 5 comments
Open

TypeError: Cannot read property 'error' of undefined on POST #314

jpenagg opened this issue Oct 18, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@jpenagg
Copy link

jpenagg commented Oct 18, 2022

Problem Description

We are seeing the app throw a TypeError when any Github event triggers the webhook. The app is running on Kubernetes and deployed with Helm.

What is actually happening

The app throws a 500 and doesn't enforce any settings defined in the admin repo.

What is the expected behavior

The app returns a 200 and enforces the settings defined in the admin repo.

Error output, if available

AggregateError: 
    TypeError: Cannot read property 'error' of undefined
        at /opt/safe-settings/lib/configManager.js:20:18
        at async ConfigManager.loadYaml (/opt/safe-settings/lib/configManager.js:19:24)
        at async syncAllSettings (/opt/safe-settings/index.js:16:29)
        at async Promise.all (index 0)
        at async middleware (/opt/safe-settings/node_modules/@octokit/webhooks/dist-node/index.js:355:5)

Context

n/a

Are you using the hosted instance of probot/settings or running your own?

Running my own.

If running your own instance, are you using it with github.com or GitHub Enterprise?

github.com.

Version of probot/settings

^12.2.8

Version of GitHub Enterprise

n/a

@jpenagg jpenagg added the bug Something isn't working label Oct 18, 2022
@arturmartins
Copy link

hello @github team. Any updates on this?

@decyjphr
Copy link
Collaborator

Hi, You would need a repo called admin and in that repo there should be a file with the path .github/settings.yml. This is explained here

Samples of these file are here

Please let me know if the file is there.

@jpenagg
Copy link
Author

jpenagg commented Nov 8, 2022

@decyjphr Hi, yes the admin repo was already set up at the time and includes the path .github/settings.yml.

I've sent the errors to console and here are a few more errors:

Error getting settings Error: error:0909006C:PEM routines:get_name:no start line
ERROR (event): Cannot read property 'data' of undefined
    TypeError: Cannot read property 'data' of undefined
        at ConfigManager.loadYaml (/opt/safe-settings/lib/configManager.js:25:34)
        at async syncSettings (/opt/safe-settings/index.js:70:29)
        at async Promise.all (index 0)
        at async middleware (/opt/safe-settings/node_modules/@octokit/webhooks/dist-node/index.js:355:5)

** payload **

INFO (http): POST / 500 - 35ms
    err: {
      "type": "Error",
      "message": "failed with status code 500",
      "stack":
          Error: failed with status code 500
              at ServerResponse.onResFinished (/opt/safe-settings/node_modules/pino-http/logger.js:77:38)
              at ServerResponse.emit (events.js:412:35)
              at ServerResponse.emit (domain.js:470:12)
              at onFinish (_http_outgoing.js:792:10)
              at callback (internal/streams/writable.js:513:21)
              at afterWrite (internal/streams/writable.js:466:5)
              at afterWriteTick (internal/streams/writable.js:453:10)
              at processTicksAndRejections (internal/process/task_queues.js:81:21)
    }

@decyjphr
Copy link
Collaborator

decyjphr commented Nov 8, 2022

Looking at the error this looks like misconfigured private key. The private key must start with -----BEGIN RSA PRIVATE KEY----- and end with -----END RSA PRIVATE KEY-----
The private key is used for authentication and so any API request including the one to get the config would fail due to that.

@jpenagg
Copy link
Author

jpenagg commented Nov 9, 2022

Thank you very much @decyjphr, that was it 😄

For context we are storing the credentials in AWS secrets manager and using the SDK to retrieve it, but the private key was malformed.

We fixed it with: privateKey: secret.private_key.replace(/\\n/g, '\n').

Thanks again! Feel free to close this issue out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants