loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.96k stars 1.07k forks source link

@loopback/testlab breaking change #6616

Closed mdbetancourt closed 3 years ago

mdbetancourt commented 4 years ago

after upgrade from testlab@3.2.5 to testlab@3.2.7 i get the following error

Error: Attempt to change mapping for "form" extension from "application/x-www-form-urlencoded" to "application/x-www-form-urlencoded". Pass force=true to allow this, otherwise remove "form" from the list of extensions for "application/x-www-form-urlencoded"

may be related to https://github.com/visionmedia/superagent/issues/1288

dep changes between versions image

christo911 commented 4 years ago

rest-builder.js line 84, setting to true solved it for me

mime.define({ 'application/x-www-form-urlencoded': ['form', 'urlencoded', 'form-body'], }, true);

raymondfeng commented 4 years ago

@mdbetancourt How do you reproduce the error?

mdbetancourt commented 3 years ago

works well with @loopback/testlab: 3.2.9

Telokis commented 1 year ago

Several years later, this exact issue is happening to me right now.

It's my first time using loopback and I've setup everything today using lb4 app.

When running yarn run test, I get the error:

  3) PingController
       "before all" hook: setupApplication for "invokes GET /ping":
     Error: Attempt to change mapping for "form" extension from "application/x-www-form-urlencoded" to "application/x-www-form-urlencoded". Pass `force=true` to allow this, otherwise remove "form" from the list of extensions for "application/x-www-form-urlencoded".
      at Mime.define (node_modules\mime\Mime.js:56:15)
      at Object.<anonymous> (node_modules\loopback-connector-rest\lib\rest-builder.js:84:6)
      at Module._compile (node:internal/modules/cjs/loader:1256:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
      at Module.load (node:internal/modules/cjs/loader:1119:32)
      at Function.Module._load (node:internal/modules/cjs/loader:960:12)
      at Module.require (node:internal/modules/cjs/loader:1143:19)
      at require (node:internal/modules/cjs/helpers:110:18)
      at Object.<anonymous> (node_modules\loopback-connector-rest\index.js:8:18)
      at Module._compile (node:internal/modules/cjs/loader:1256:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
      at Module.load (node:internal/modules/cjs/loader:1119:32)
      at Function.Module._load (node:internal/modules/cjs/loader:960:12)
      at Module.require (node:internal/modules/cjs/loader:1143:19)
      at require (node:internal/modules/cjs/helpers:110:18)
      at tryModules (node_modules\loopback-datasource-juggler\lib\datasource.js:260:13)
      at Function.DataSource._resolveConnector (node_modules\loopback-datasource-juggler\lib\datasource.js:288:21)
      at AdventureLandDataSource.DataSource.setup (node_modules\loopback-datasource-juggler\lib\datasource.js:462:31)
      at new DataSource (node_modules\loopback-datasource-juggler\lib\datasource.js:147:8)
      at new AdventureLandDataSource (src\datasources\adventure-land.datasource.ts:45:5)
      at C:\Users\Telokis\Documents\Dev\Git\teloalapi\node_modules\@loopback\context\src\resolver.ts:76:14
      at transformValueOrPromise (node_modules\@loopback\context\src\value-promise.ts:298:12)
      at instantiateClass (node_modules\@loopback\context\src\resolver.ts:69:58)
      at C:\Users\Telokis\Documents\Dev\Git\teloalapi\node_modules\@loopback\context\src\binding.ts:886:37
      at Binding._getValue (node_modules\@loopback\context\src\binding.ts:724:14)
      at C:\Users\Telokis\Documents\Dev\Git\teloalapi\node_modules\@loopback\context\src\binding.ts:548:23
      at C:\Users\Telokis\Documents\Dev\Git\teloalapi\node_modules\@loopback\context\src\resolution-session.ts:109:13
      at tryCatchFinally (node_modules\@loopback\context\src\value-promise.ts:222:14)
      at tryWithFinally (node_modules\@loopback\context\src\value-promise.ts:197:10)
      at Function.runWithBinding (node_modules\@loopback\context\src\resolution-session.ts:108:26)
      at Binding.getValue (node_modules\@loopback\context\src\binding.ts:538:40)
      at C:\Users\Telokis\Documents\Dev\Git\teloalapi\node_modules\@loopback\context\src\context-view.ts:211:16
      at resolveList (node_modules\@loopback\context\src\value-promise.ts:169:28)
      at ContextView.resolve (node_modules\@loopback\context\src\context-view.ts:202:29)
      at ContextView.values (node_modules\@loopback\context\src\context-view.ts:240:19)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at LifeCycleObserverRegistry.notifyGroups (node_modules\@loopback\core\src\lifecycle-registry.ts:209:23)
      at LifeCycleObserverRegistry.init (node_modules\@loopback\core\src\lifecycle-registry.ts:247:5)
      at TeloALApi.init (node_modules\@loopback\core\src\application.ts:318:5)
      at TeloALApi.start (node_modules\@loopback\core\src\application.ts:356:29)
      at TeloALApi.start (node_modules\@loopback\boot\src\mixins\boot.mixin.ts:76:7)
      at setupApplication (src\__tests__\acceptance\test-helper.ts:18:3)
      at Context.<anonymous> (src\__tests__\acceptance\ping.controller.acceptance.ts:10:24)

This is the default test, I haven't altered it yet. When looking at the specified line, I can indeed see the missing true specified above.

lb4 --version ``` > lb4 --version @loopback/cli version: 5.2.1 @loopback/* dependencies: - @loopback/authentication: ^10.1.2 - @loopback/boot: ^6.1.2 - @loopback/build: ^10.1.2 - @loopback/context: ^6.1.2 - @loopback/core: ^5.1.2 - @loopback/metadata: ^6.1.2 - @loopback/openapi-spec-builder: ^6.1.2 - @loopback/openapi-v3: ^9.1.2 - @loopback/repository-json-schema: ^7.1.2 - @loopback/repository: ^6.1.2 - @loopback/rest: ^13.1.2 - @loopback/testlab: ^6.1.2 - @loopback/docs: ^6.0.3 - @loopback/example-hello-world: ^6.1.2 - @loopback/example-log-extension: ^6.1.2 - @loopback/example-rpc-server: ^6.1.2 - @loopback/example-todo: ^7.1.2 - @loopback/example-soap-calculator: ^6.1.2 - @loopback/service-proxy: ^6.1.2 - @loopback/http-caching-proxy: ^5.1.2 - @loopback/http-server: ^5.1.2 - @loopback/example-todo-list: ^7.1.2 - @loopback/dist-util: ^0.4.0 - @loopback/rest-explorer: ^6.1.2 - @loopback/eslint-config: ^14.0.3 - @loopback/example-express-composition: ^6.1.2 - @loopback/example-greeter-extension: ^6.1.2 - @loopback/booter-lb3app: ^5.1.2 - @loopback/example-lb3-application: ^6.1.2 - @loopback/example-greeting-app: ^6.1.2 - @loopback/example-context: ^6.1.2 - @loopback/repository-tests: ^0.23.2 - @loopback/health: ^0.13.2 - @loopback/authorization: ^0.14.2 - @loopback/rest-crud: ^0.17.2 - @loopback/security: ^0.10.2 - @loopback/authentication-passport: ^6.1.2 - @loopback/example-metrics-prometheus: ^0.12.2 - @loopback/metrics: ^0.13.2 - @loopback/model-api-builder: ^5.1.2 - @loopback/logging: ^0.11.2 - @loopback/example-access-control-migration: ^6.1.2 - @loopback/example-file-transfer: ^5.1.2 - @loopback/example-rest-crud: ^5.1.2 - @loopback/apiconnect: ^0.12.2 - @loopback/example-validation-app: ^5.1.2 - @loopback/cron: ^0.11.2 - @loopback/example-multi-tenancy: ^0.15.2 - @loopback/example-passport-login: ^5.1.2 - @loopback/authentication-jwt: ^0.14.2 - @loopback/context-explorer: ^0.10.2 - @loopback/express: ^6.1.2 - @loopback/example-todo-jwt: ^5.1.2 - @loopback/mock-oauth2-provider: ^0.8.2 - @loopback/pooling: ^0.10.2 - @loopback/typeorm: ^0.9.2 - @loopback/example-graphql: ^0.9.2 - @loopback/graphql: ^0.10.2 - @loopback/filter: ^4.1.2 - @loopback/rest-msgpack: ^0.10.2 - @loopback/example-binding-resolution: ^0.9.2 - @loopback/example-webpack: ^0.10.2 - @loopback/example-socketio: ^0.8.2 - @loopback/socketio: ^0.7.3 - @loopback/monorepo: ^0.6.0 - @loopback/tsdocs: ^5.1.2 - @loopback/example-references-many: ^7.1.2 - @loopback/sequelize: ^0.5.1 ```

I am using node v18.16.1.