Kong / Kong/insomnia

Exception when generating declarative config for Kubernetes with security scheme

Open
#3,881 2 comments 2 reactions 0 assignees View on GitHub
B-bug PA-inso PA-openapi-2-kong S-verified
Dominant language
TypeScript
Stars
40k
Forks
2.4k
Avg merge
2d 13h
Merged PRs (30d)
61

Description

**Describe the bug**
An exception occurs in both Insomnia App and Inso CLI when trying to generate a declarative config for Kubernetes from an OAS spec file that includes a security scheme.

**To Reproduce**
Steps to reproduce the behavior:
1. Add `security.apikey: []` to any spec (a [valid security scheme](https://swagger.io/docs/specification/authentication/))
2. Try to generate declarative config for Kubernetes in the App or try to run `inso generate config -t kubernetes`

**Expected behavior**
Declarative config for Kubernetes successfully generated.

**CLI output**
```bash
$ inso generate config my-spec.yaml -t kubernetes 1 ↵

FATAL There was an error while generating configuration

ERROR Cannot read property 'toLowerCase' of undefined

at generateSecurityPlugin (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/declarative-config/security-plugins.js:74:73)
at Object.generateSecurityPlugins (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/declarative-config/security-plugins.js:14:28)
at getGlobalPlugins (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/kubernetes/plugins.js:61:73)
at Object.getPlugins (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/kubernetes/plugins.js:32:17)
at Object.generateKongForKubernetesConfigFromSpec (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/kubernetes/generate.js:14:31)
at Object.generateFromSpec (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/generate.js:48:31)
at Object.generateFromString (/Users/cwurm/.nvm/versions/node/v10.21.0/lib/node_modules/insomnia-inso/node_modules/openapi-2-kong/dist/generate.js:56:20)

ℹ To view tracing information, re-run inso with --verbose
```

**Version:**
- OS: macOS 11.4
- Installation Method: npm
- App Version: Insomnia CLI 2.3.0 (`inso -version`)

**Additional context**

Sample OAS file causing this:
```
openapi: 3.0.0
servers:
- url: http://api.example.com/v1
security:
- apiKey: []
paths:
/users:
get:
```

Contributor guide

Open the contributing guide

Research direction

Reproduce with the sample OAS and the `inso generate config -t kubernetes` entry point. Inspect `security-plugins.js`, `kubernetes/plugins.js`, and the related `openapi-2-kong` generation path named in the stack trace. Done means Kubernetes declarative configuration generates successfully when the specification includes `security.apikey: []`.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, openapi, typescript
Domain
api, cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.