{"record":{"id":"b82554e20730244b","repo":"toeverything/AFFiNE","slug":"valuenotexists-b82554","errorCode":"ValueNotExists","errorMessage":"EmbedIframeService or LinkPreviewService not found","messagePattern":"EmbedIframeService or LinkPreviewService not found","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/embed/src/embed-iframe-block/embed-iframe-block.ts","lineNumber":163,"sourceCode":"  };\n\n  refreshData = async () => {\n    try {\n      const { url } = this.model.props;\n      if (!url) {\n        this.status$.value = 'idle';\n        return false;\n      }\n\n      // set loading status\n      this.status$.value = 'loading';\n      this.error$.value = null;\n\n      // get embed data\n      const embedIframeService = this.embedIframeService;\n      const linkPreviewService = this.linkPreviewService;\n      if (!embedIframeService || !linkPreviewService) {\n        throw new BlockSuiteError(\n          ErrorCode.ValueNotExists,\n          'EmbedIframeService or LinkPreviewService not found'\n        );\n      }\n\n      // get embed data and preview data in a promise\n      const [embedData, previewData] = await Promise.all([\n        embedIframeService.getEmbedIframeData(url),\n        linkPreviewService.query(url),\n      ]);\n\n      // if the embed data is not found, and the iframeUrl is not set, throw an error\n      const currentIframeUrl = this.model.props.iframeUrl;\n      if (!embedData && !currentIframeUrl) {\n        throw new BlockSuiteError(\n          ErrorCode.ValueNotExists,\n          'Failed to get embed data'\n        );","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/blocks/embed/src/embed-iframe-block/embed-iframe-block.ts#L145-L181","documentation":"parseIdentifier accepts only two shapes: an Identifier created by createIdentifier (a callable carrying identifierName/variant), or a named class/constructor from which a stable name+hash identifier is derived. Anything else — strings, undefined, numbers, plain objects, anonymous functions — cannot be mapped to a service key, so it throws 'Input is not a service identifier.' before any registry lookup happens. Unlike string-token DI libraries (inversify/tsyringe), raw strings are not valid tokens here.","triggerScenarios":"provider.get('Storage') expecting a string token; passing undefined because a circular ESM import left the identifier module half-evaluated; passing a plain object or a value obtained by destructuring/wrapping the Identifier; passing an anonymous function expression (empty .name).","commonSituations":"Migrating code from a string-token DI container; circular imports where `export const Storage = createIdentifier(...)` is consumed before evaluation; identifiers re-exported through barrel files involved in a cycle.","solutions":["Create identifiers with createIdentifier<T>('Name') and pass that callable to impl/get/getAll","Fix the circular import so the identifier is defined when get()/impl() runs — move identifiers to a leaf module or reorder imports","Never pass strings or plain objects as identifiers; if you meant class-as-identifier, pass the class itself (it must have a .name)"],"exampleFix":"// before\nprovider.get('Storage'); // strings are not identifiers\n\n// after\nconst Storage = createIdentifier<Storage>('Storage');\nfw.impl(Storage, LocalStorage);\nprovider.get(Storage);","handlingStrategy":"type-guard","validationCode":"null","typeGuard":"function isIdentifier<T>(x: unknown): x is Identifier<T> {\n  return typeof x === 'function' && typeof (x as any).identifierName === 'string';\n}\n\n// guard before resolving\nif (!isIdentifier(Storage)) throw new Error('Storage identifier not initialized (circular import?)');\nprovider.get(Storage);","tryCatchPattern":null,"preventionTips":["Always create tokens with createIdentifier() — string tokens are not supported","Keep identifier modules leaf-level (no imports of consumers) to avoid circular-import undefined tokens","If an identifier can arrive from untrusted wiring, isIdentifier() it before calling get/impl"],"tags":["dependency-injection","identifier","invalid-argument","circular-import"],"backgroundTag":"invalid-di-token","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"}