{"record":{"id":"548aab282c2eba56","repo":"toeverything/AFFiNE","slug":"invalid-google-drive-iframe-url","errorCode":null,"errorMessage":"Invalid Google Drive iframe URL:","messagePattern":"Invalid Google Drive iframe URL:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/embed/src/embed-iframe-block/configs/providers/google-drive.ts","lineNumber":134,"sourceCode":"function isValidGoogleDriveIframeUrl(url: string): boolean {\n  try {\n    if (!validateEmbedIframeUrl(url, googleDriveUrlValidationOptions)) {\n      return false;\n    }\n\n    const parsedUrl = new URL(url);\n    const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);\n\n    if (isValidGoogleDriveFileUrl(parsedUrl)) {\n      return pathSegments[3] === 'preview';\n    }\n\n    return (\n      parsedUrl.pathname === '/embeddedfolderview' &&\n      !!parsedUrl.searchParams.get('id')\n    );\n  } catch (e) {\n    console.warn('Invalid Google Drive iframe URL:', e);\n    return false;\n  }\n}\n\n/**\n * Build embed URL for Google Drive files\n * @param fileId File ID\n * @returns Embed URL\n */\nfunction buildGoogleDriveFileEmbedUrl(fileId: string): string | undefined {\n  const embedUrl = new URL(\n    'preview',\n    `${GOOGLE_DRIVE_EMBED_FILE_URL}${fileId}/`\n  );\n  embedUrl.searchParams.set('usp', 'embed_googleplus');\n  return embedUrl.toString();\n}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/blocks/embed/src/embed-iframe-block/configs/providers/google-drive.ts#L116-L152","documentation":"Warning logged in `isValidGoogleDriveIframeUrl` when `new URL(url)` throws because the candidate URL is malformed. The function returns false, so the URL is treated as an invalid Google Drive embed and filtered out of the provider config — a validation guard against unparseable user input.","triggerScenarios":"Triggered when new URL() throws while checking whether a Google Drive iframe URL is a valid preview or embedded folder URL, so the check returns false.","commonSituations":"Occurs when a user supplies a malformed Google Drive link to the embed iframe block. Paste a valid drive.google.com share URL instead.","solutions":["Use a valid Google Drive share/embed URL.","Copy the embed URL from Google Drive's share dialog."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}