{"record":{"id":"c4fddf7bb1cfa171","repo":"appsmithorg/appsmith","slug":"cannot-find-iframe-with-name-source-on-this-pag","errorCode":null,"errorMessage":"Cannot find Iframe with name ${source} on this page","messagePattern":"Cannot find Iframe with name (.+?) on this page","errorType":"exception","errorClass":"TriggerFailureError","httpStatus":null,"severity":"error","filePath":"app/client/src/sagas/ActionExecution/PostMessageSaga.ts","lineNumber":32,"sourceCode":"\nexport function* executePostMessage(\n  payload: TPostWindowMessageDescription[\"payload\"],\n) {\n  const { message, source, targetOrigin } = payload;\n\n  try {\n    if (isEmpty(targetOrigin)) {\n      throw new TriggerFailureError(\"Please enter a target origin URL.\");\n    } else {\n      if (source !== \"window\") {\n        const src = document.getElementById(\n          `iframe-${source}`,\n        ) as HTMLIFrameElement;\n\n        if (src && src.contentWindow) {\n          src.contentWindow.postMessage(message, targetOrigin);\n        } else {\n          throw new TriggerFailureError(\n            `Cannot find Iframe with name ${source} on this page`,\n          );\n        }\n      } else {\n        window.parent.postMessage(message, targetOrigin, undefined);\n      }\n    }\n  } catch (error) {\n    yield call(showToastOnExecutionError, (error as Error).message);\n  }\n}\n","sourceCodeStart":14,"sourceCodeEnd":44,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/src/sagas/ActionExecution/PostMessageSaga.ts#L14-L44","documentation":"TriggerFailureError thrown by executePostMessage when source is not 'window' and no iframe element with id `iframe-${source}` (or an iframe without a contentWindow) exists in the DOM. The saga uses getElementById, so a missing widget, a wrong id, or an iframe that hasn't attached its contentWindow yet all collapse to this single error.","triggerScenarios":"source references an iframe widget that is not rendered on the current page, is misspelled, or has been deleted; the iframe widget exists but is hidden/unmounted; the iframe loaded a sandboxed document that exposed no contentWindow.","commonSituations":"Typo in the source field; iframe widget sits on a different page/tab; the iframe's src is cross-origin and the inner document was swapped out; calling postWindowMessage during initial render before the iframe mounts.","solutions":["Confirm an iframe widget with the exact name supplied in source is present on the current page.","Set source to 'window' if the intent is to message the parent window, not an iframe.","Delay the call (onPageLoad false, or via setTimeout in a JS object) until after the iframe's onSrcChangeReady event confirms it has loaded."],"exampleFix":"// before: no iframe named 'foo' on page\npostWindowMessage({ source: 'foo', targetOrigin: 'https://x.com', message: 'hi' });\n// after: post to parent window instead\npostWindowMessage({ source: 'window', targetOrigin: 'https://x.com', message: 'hi' });","handlingStrategy":"validation","validationCode":"const iframe = document.getElementById(`iframe-${source}`);\nif (source !== 'window' && (!iframe || !(iframe as HTMLIFrameElement).contentWindow)) {\n  showAlert(`Iframe '${source}' is not available`, 'error');\n  return;\n}","typeGuard":"function iframeReady(name: string): boolean {\n  const el = document.getElementById(`iframe-${name}`) as HTMLIFrameElement | null;\n  return !!el && !!el.contentWindow;\n}","tryCatchPattern":"try {\n  postWindowMessage({ source, targetOrigin, message });\n} catch (e) {\n  if (e instanceof TriggerFailureError) showAlert(e.message, 'error');\n}","preventionTips":["Confirm the iframe widget name exists on the page before binding source.","Use source='window' when messaging the parent rather than an iframe.","Fire the call after the iframe's onSrcChangeReady event, not on page load."],"tags":["postmessage","iframe","widget-reference"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}