{"record":{"id":"512c76bf067b6974","repo":"nestjs/nest","slug":"a-circular-dependency-has-been-detected-inside-c","errorCode":null,"errorMessage":"A circular dependency has been detected inside ${context}. Please, make sure that each side of a bidirectional relationships are decorated with \"forwardRef()\". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once.","messagePattern":"A circular dependency has been detected inside (.+?)\\. Please, make sure that each side of a bidirectional relationships are decorated with \"forwardRef\\(\\)\"\\. Note that circular relationships between custom providers \\(e\\.g\\., factories\\) are not supported since functions cannot be called more than once\\.","errorType":"exception","errorClass":"CircularDependencyException","httpStatus":null,"severity":"error","filePath":"packages/core/injector/container.ts","lineNumber":260,"sourceCode":"  ) {\n    if (!this.modules.has(token)) {\n      return;\n    }\n    const moduleRef = this.modules.get(token)!;\n    const { token: relatedModuleToken } =\n      await this.moduleCompiler.compile(relatedModule);\n    const related = this.modules.get(relatedModuleToken)!;\n    moduleRef.addImport(related);\n  }\n\n  public addProvider(\n    provider: Provider,\n    token: string,\n    enhancerSubtype?: EnhancerSubtype,\n  ): string | symbol | Function {\n    const moduleRef = this.modules.get(token);\n    if (!provider) {\n      throw new CircularDependencyException(moduleRef?.metatype.name);\n    }\n    if (!moduleRef) {\n      throw new UnknownModuleException();\n    }\n    const providerKey = moduleRef.addProvider(provider, enhancerSubtype!);\n    const providerRef = moduleRef.getProviderByKey(providerKey);\n\n    DiscoverableMetaHostCollection.inspectProvider(this.modules, providerRef);\n\n    return providerKey as Function;\n  }\n\n  public addInjectable(\n    injectable: Provider,\n    token: string,\n    enhancerSubtype: EnhancerSubtype,\n    host?: Type<Injectable>,\n  ) {","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/nestjs/nest/blob/dd75d7bd8c5e88048587e6768d36eb695f3e7a25/packages/core/injector/container.ts#L242-L278","documentation":"Error \"A circular dependency has been detected inside ${context}. Please, make sure that each side of a bidirectional relationships are decorated with \"forwardRef()\". Note that circular relationships between custom providers (e.g., factories) are not supported since functions cannot be called more than once.\" thrown in nestjs/nest.","triggerScenarios":"Thrown at packages/core/injector/container.ts:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"dd75d7bd8c5e88048587e6768d36eb695f3e7a25","analyzedAt":"2026-08-21T19:39:39.867Z","contentChangedAt":"2026-08-21T19:39:39.867Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}