{"record":{"id":"d5168bc2b5decfaa","repo":"toeverything/AFFiNE","slug":"valuenotexists","errorCode":"ValueNotExists","errorMessage":"property ${propertyId} not found","messagePattern":"property (.+?) not found","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/data-view/src/data-source.ts","lineNumber":104,"sourceCode":"    this.workspace.slots.docListUpdated.subscribe(() => {\n      this.workspace.docs.forEach(doc => {\n        if (!this.docDisposeMap.has(doc.id)) {\n          this.listenToDoc(doc.getStore());\n        }\n      });\n      this.docDisposeMap.forEach((_, id) => {\n        if (!this.workspace.docs.has(id)) {\n          this.docDisposeMap.get(id)?.();\n          this.docDisposeMap.delete(id);\n        }\n      });\n    });\n  }\n\n  private getProperty(propertyId: string) {\n    const property = this.meta.properties.find(v => v.key === propertyId);\n    if (!property) {\n      throw new BlockSuiteError(\n        BlockSuiteError.ErrorCode.ValueNotExists,\n        `property ${propertyId} not found`\n      );\n    }\n    return property;\n  }\n\n  private newColumnName() {\n    let i = 1;\n    while (\n      this.block.props.columns.some(column => column.name === `Column ${i}`)\n    ) {\n      i++;\n    }\n    return `Column ${i}`;\n  }\n\n  cellValueChange(rowId: string, propertyId: string, value: unknown): void {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/blocks/data-view/src/data-source.ts#L86-L122","documentation":"The base Component class (parent of Service, Store, Entity, Scope) gets its framework provider and props from a module-level CONSTRUCTOR_CONTEXT that is only populated while the DI container runs a component factory (via withContext). Constructing any Component subclass outside that synchronous window leaves CONSTRUCTOR_CONTEXT.current.provider undefined, so the constructor aborts immediately. This guarantees every component is born with a backing provider (framework, eventBus, DI) instead of existing half-initialized.","triggerScenarios":"Calling `new MyService(...)` directly in app code or tests; writing a custom factory like `framework.impl(Identifier, () => new MyService())` — a plain arrow factory runs outside withContext; constructing a Component subclass inside an async continuation (Promise.then) that escaped the factory call.","commonSituations":"Unit tests that construct services manually to skip Framework setup; refactoring a POJO that was previously `new`-ed into a Component subclass; passing a hand-written factory function to impl() instead of the class plus deps array, so the container never wraps construction in context.","solutions":["Never instantiate Component subclasses yourself: register with framework.service(MyService, [Deps]) / framework.impl(Identifier, MyService) and obtain instances via provider.get(MyService), provider.createEntity(...)","When registering with a custom factory, accept the resolver argument and resolve dependencies inside it; better, pass the class + deps array so dependenciesToFactory constructs it within provider context","In tests, build a minimal Framework (new Framework()), register the unit under test plus its dependencies, and instantiate through framework.provider().get(...)"],"exampleFix":"// before\nconst s = new MyService(dep); // throws: no provider context\n\n// after\nconst fw = new Framework();\nfw.service(MyService, [MyDep]); // container constructs it in context\nconst s = fw.provider().get(MyService);","handlingStrategy":"validation","validationCode":"null","typeGuard":"null","tryCatchPattern":null,"preventionTips":["Treat Component/Service/Store/Entity constructors as container-private: never call new on them in app code","Register classes with their dependency arrays (framework.service/impl) so the container constructs them inside withContext","In custom factories passed to impl(), accept the resolver parameter and let the container invoke the factory","In tests, spin up a minimal Framework and resolve through framework.provider().get(...) instead of direct construction"],"tags":["dependency-injection","component-lifecycle","constructor","context"],"backgroundTag":"di-component-instantiated-outside-container","analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}