question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read security of undefined

See original GitHub issue

Hi,

Im trying to make it work, but Im getting this error

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'security' of undefined
starter-node-documentation       |     at /usr/app/node_modules/express-openapi-validator/dist/middlewares/openapi.security.js:16:47
starter-node-documentation       |     at Layer.handle [as handle_request] (/usr/app/node_modules/express/lib/router/layer.js:95:5)
starter-node-documentation       |     at trim_prefix (/usr/app/node_modules/express/lib/router/index.js:317:13)
starter-node-documentation       |     at /usr/app/node_modules/express/lib/router/index.js:284:7
starter-node-documentation       |     at Function.process_params (/usr/app/node_modules/express/lib/router/index.js:335:12)
starter-node-documentation       |     at next (/usr/app/node_modules/express/lib/router/index.js:275:10)
starter-node-documentation       |     at /usr/app/node_modules/express-openapi-validator/dist/middlewares/openapi.multipart.js:37:13
starter-node-documentation       |     at Layer.handle [as handle_request] (/usr/app/node_modules/express/lib/router/layer.js:95:5)
starter-node-documentation       |     at trim_prefix (/usr/app/node_modules/express/lib/router/index.js:317:13)
starter-node-documentation       |     at /usr/app/node_modules/express/lib/router/index.js:284:7

Im using node, docker, express etc.

Here is my code:

// some code above
const documentation = require('./components/documentation')
// some code below

new OpenApiValidator({
  apiSpec: documentation,
  validateResponses: true
}).install(app)

documentation is JSON object. According to error, which is pointing on row 16, it looks like problem is here: const securities = req.openapi.schema.security || context.apiDoc.security;

I tried to add security[] to my documentation, but it doesnt work, so I assume problem is req.openapi.schema.scurity. To makes it clear, my app has 2 backends, one is for app, which is used by FE (there are all routes like get/post/…), second one is for OpenAPI documentation (we are using swagger-ui-express, nothing for production, thats why validator is here) which is using first one, where are all routes.

My questions is: its something with validator or where validator is using (BE for OpenAPI - no production)

Thank you 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
LadIQecommented, Oct 24, 2019

Yes this should be helpful for users 😃 thank you

0reactions
LadIQecommented, Oct 24, 2019

Thats absolutely ok 😃 I appreciate your effort 😃 thank you very much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot read properties of undefined (reading 'includes')
When I am trying to access security from kibana dashboard I'm getting this error. Error Error: Cannot read properties of undefined (reading ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Mysterious error that happens when Lightning Web Security is ...
Mysterious error that happens when Lightning Web Security is turned on: Cannot read properties of undefined (reading 'copy') · Ask Question.
Read more >
Error: Cannot read property "attach_url" from undefined
I am using Flow designer to trigger custom API call using an Action to get an output and attach it to the Incident...
Read more >
Cannot read properties of undefined (reading 'securityService')
security.controller: /* eslint-disable no-console */ import { IRouter, Request, Response } from 'express' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found