backstage / backstage/community-plugins

๐Ÿ› RBAC: backend startup fails due to missing mongodb dependency

Open Beginner friendly
#9,764 2 comments 0 reactions 0 assignees View on GitHub
bug workspace/rbac
Dominant language
TypeScript
Stars
422
Forks
697
Avg merge
2d 6h
Merged PRs (30d)
286

Description

### Workspace

rbac

### ๐Ÿ“œ Description

The `typeorm-adapter` version 1.10.0 contains a bug which prevent the backstage backend to complete the startup process.

The current workaround is to install the `mongdb` dependencie in the backend package

```bash
yarn workspace backend add mongodb@^7.4.0
```

> This issue i know by the `apache/casbin-typeorm-adapter` and a PR has been opened
> https://github.com/apache/casbin-typeorm-adapter/issues/81

### ๐Ÿ‘ Expected behavior

The backstage backend should start without adding the `mongodb` package to the `backend` package

### ๐Ÿ‘Ž Actual Behavior with Screenshots

n/a

### ๐Ÿ‘Ÿ Reproduction steps

Install the `backstage-community/plugin-rbac-backend@7.16.0` in fresh backstage app
launch the app `yarn start`

the app should failt to start the backend

### ๐Ÿ“ƒ Provide the context for the Bug.

Backstage backend fails to start

```bash
Error: Cannot find module 'mongodb'
Require stack:
- /REDACTED/backstage/src/node_modules/typeorm-adapter/lib/casbinMongoRule.js
- /REDACTED/backstage/src/node_modules/typeorm-adapter/lib/index.js
- /REDACTED/backstage/src/node_modules/@backstage-community/plugin-rbac-backend/dist/database/casbin-adapter-factory.cjs.js
- /REDACTED/backstage/src/node_modules/@backstage-community/plugin-rbac-backend/dist/service/policy-builder.cjs.js
- /REDACTED/backstage/src/node_modules/@backstage-community/plugin-rbac-backend/dist/index.cjs.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1383:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
at Module._load (node:internal/modules/cjs/loader:1192:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
at Module.require (node:internal/modules/cjs/loader:1463:12)
at Module.patchedRequire (/REDACTED/backstage/src/node_modules/require-in-the-middle/index.js:186:34)
at Hook._require.Module.require (/REDACTED/backstage/src/node_modules/require-in-the-middle/index.js:134:27)
at require (node:internal/modules/helpers:147:16)
at Object. (/REDACTED/backstage/src/node_modules/typeorm-adapter/lib/casbinMongoRule.js:26:19)
at Module._compile (node:internal/modules/cjs/loader:1706:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1839:10)
at Object.newLoader [as .js] (/REDACTED/backstage/src/node_modules/pirates/lib/index.js:134:7)
at Module.load (node:internal/modules/cjs/loader:1441:32)
at Module._load (node:internal/modules/cjs/loader:1263:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/REDACTED/backstage/src/node_modules/typeorm-adapter/lib/casbinMongoRule.js',
'/REDACTED/backstage/src/node_modules/typeorm-adapter/lib/index.js',
'/REDACTED/backstage/src/node_modules/@backstage-community/plugin-rbac-backend/dist/database/casbin-adapter-factory.cjs.js',
'/REDACTED/backstage/src/node_modules/@backstage-community/plugin-rbac-backend/dist/service/policy-builder.cjs.js',
'/REDACTED/backstage/src/node_modules/@backstage-community/plugin-rbac-backend/dist/index.cjs.js'
]
}
```

### ๐Ÿ‘€ Have you spent some time to check if this bug has been raised before?

- [x] I checked and didn't find similar issue

### ๐Ÿข Have you read the Code of Conduct?

- [x] I have read the [Code of Conduct](https://github.com/backstage/community-plugins/blob/main/CODE_OF_CONDUCT.md)

### Are you willing to submit PR?

Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure by installing backstage-community/plugin-rbac-backend@7.16.0 in a fresh Backstage app and running yarn start. Trace the missing mongodb import through typeorm-adapter/lib/casbinMongoRule.js and the RBAC backend package, then verify that the backend starts without manually adding mongodb to the backend workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
authorization, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.