{"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/26c515e050211269e911f7d9cfe162a26c83ed98/blocksuite/affine/blocks/embed/src/embed-iframe-block/embed-iframe-block.ts#L145-L181","documentation":"Thrown by EmbedIframeBlockComponent.refreshData when either EmbedIframeService or LinkPreviewService is not resolvable from the std dependency-injection container (this.std.get(...) returned undefined). These services are optional DI providers; the embed-iframe block cannot fetch embed or link-preview metadata without them. The whole refresh is wrapped in try/catch and surfaces as status$='error', so the throw is converted to a user-facing error state rather than a crash.","triggerScenarios":"Calling embedIframeBlock.refreshData() (or any flow that triggers it, such as pasting a link or pressing refresh) in an editor setup where EmbedIframeService and/or LinkPreviewServiceIdentifier were never registered with the std DI container. Common when embedding the block in a custom/lightweight editor flavour that omits the embed-service extensions.","commonSituations":"Custom integrations that mount only a subset of BlockSuite extensions; tree-shaking or feature-flag configurations that drop the embed-iframe services; upgrades where the service identifier token changed but the registration was not updated.","solutions":["Register EmbedIframeService and a LinkPreviewService implementation in your editor's std extensions before mounting the embed-iframe block.","If link preview is intentionally unavailable, provide a no-op LinkPreviewService so the dependency resolves (query returns null) and only embed data is required downstream.","Subscribe to embedIframeBlock.status$ / error$ to surface the missing-service state to users instead of silently failing."],"exampleFix":"// before\n// EmbedIframeService not registered -> refreshData throws ValueNotExists\n\n// after\nimport { EmbedIframeService } from '@blocksuite/affine-shared/services';\nstdBuilder.add(EmbedIframeService, /* link preview provider */);","handlingStrategy":"validation","validationCode":"const embed = std.get(EmbedIframeService);\nconst link = std.get(LinkPreviewServiceIdentifier);\nconst ready = !!embed && !!link;\n// only call refreshData when ready, else register the services first","typeGuard":"function hasEmbedServices(std) {\n  return !!std.get(EmbedIframeService) && !!std.get(LinkPreviewServiceIdentifier);\n}","tryCatchPattern":"embedIframeBlock.status$.subscribe(s => {\n  if (s === 'error' && embedIframeBlock.error$.value?.message.includes('not found')) {\n    // prompt user: embed services unavailable in this editor\n  }\n});","preventionTips":["Register EmbedIframeService and a LinkPreviewService in your std extensions before mounting the block.","Provide a no-op LinkPreviewService when link preview is intentionally disabled.","Surface status$='error' to users instead of failing silently."],"tags":["embed-iframe","dependency-injection","service-missing","value-not-exists"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}