{"record":{"id":"fc3875752d50d783","repo":"toeverything/AFFiNE","slug":"valuenotexists-fc3875","errorCode":"ValueNotExists","errorMessage":"Key is not defined in the EdgelessClipboardConfig","messagePattern":"Key is not defined in the EdgelessClipboardConfig","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/surface/src/extensions/clipboard-config.ts","lineNumber":65,"sourceCode":"    index?: number\n  ) => {\n    const block = await this.std.clipboard.pasteBlockSnapshot(\n      snapshot,\n      doc,\n      parent,\n      index\n    );\n    return block?.id ?? null;\n  };\n\n  abstract createBlock(\n    snapshot: BlockSnapshot,\n    context: ClipboardConfigCreationContext\n  ): string | null | Promise<string | null>;\n\n  static override setup(di: Container) {\n    if (!this.key) {\n      throw new BlockSuiteError(\n        BlockSuiteError.ErrorCode.ValueNotExists,\n        'Key is not defined in the EdgelessClipboardConfig'\n      );\n    }\n\n    di.add(\n      this as unknown as { new (std: BlockStdScope): EdgelessClipboardConfig },\n      [StdIdentifier]\n    );\n\n    di.addImpl(EdgelessClipboardConfigIdentifier(this.key), provider =>\n      provider.get(this)\n    );\n  }\n}\n","sourceCodeStart":47,"sourceCodeEnd":81,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/26c515e050211269e911f7d9cfe162a26c83ed98/blocksuite/affine/blocks/surface/src/extensions/clipboard-config.ts#L47-L81","documentation":"Thrown by EdgelessClipboardConfig.setup (the static DI registration hook) when the subclass has not defined the static 'key' property. The key is used to build EdgelessClipboardConfigIdentifier(this.key), so an empty/undefined key makes the clipboard config unidentifiable in the DI container. Error code ValueNotExists. This is a developer/registration-time error, not a runtime user error.","triggerScenarios":"Creating a subclass of EdgelessClipboardConfig (a custom clipboard behaviour for an edgeless block flavour) and registering it via the framework without declaring `static key: string = '...'`. The error fires when the extension system calls setup(di) during editor initialisation.","commonSituations":"Authoring a new edgeless block with custom paste behaviour and forgetting the static key; refactor that renames/removes the key field; copy-paste of an existing config subclass minus the key declaration.","solutions":["Declare a unique static key on every EdgelessClipboardConfig subclass: `static override key = 'affine:my-block-clipboard';`.","Use a stable, namespaced string so the identifier round-trips consistently across versions.","Add a unit test that imports each config subclass and asserts typeof Subclass.key === 'string' && Subclass.key.length > 0."],"exampleFix":"// before\nclass MyBlockClipboard extends EdgelessClipboardConfig {\n  // no static key -> setup throws ValueNotExists\n  createBlock(...) { ... }\n}\n\n// after\nclass MyBlockClipboard extends EdgelessClipboardConfig {\n  static override key = 'affine:my-block-clipboard';\n  createBlock(...) { ... }\n}","handlingStrategy":"validation","validationCode":"import { EdgelessClipboardConfig } from '@blocksuite/affine-block-surface';\n// assert at module load / in a test:\nif (typeof MyClipboardConfig.key !== 'string' || !MyClipboardConfig.key) {\n  throw new Error('MyClipboardConfig must define static key');\n}","typeGuard":"function hasClipboardKey(Ctor) {\n  return typeof Ctor.key === 'string' && Ctor.key.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always declare `static override key = '...'` on EdgelessClipboardConfig subclasses.","Use stable, namespaced key strings.","Add a unit test asserting each config subclass has a non-empty static key."],"tags":["clipboard","edgeless","dependency-injection","registration"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}