{"record":{"id":"7422cd3ee63e8244","repo":"GoogleChrome/lighthouse","slug":"getstandalonereporthtml-is-not-set","errorCode":null,"errorMessage":"`getStandaloneReportHTML` is not set","messagePattern":"`getStandaloneReportHTML` is not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"report/renderer/report-ui-features.js","lineNumber":167,"sourceCode":"    const buttonEl = this._dom.createChildOf(buttonsEl, 'button', classes.join(' '));\n    buttonEl.textContent = opts.text;\n    buttonEl.addEventListener('click', opts.onClick);\n    return buttonEl;\n  }\n\n  resetUIState() {\n    if (this._topbar) {\n      this._topbar.resetUIState();\n    }\n  }\n\n  /**\n   * Returns the html that recreates this report.\n   * @return {string}\n   */\n  getReportHtml() {\n    if (!this._opts.getStandaloneReportHTML) {\n      throw new Error('`getStandaloneReportHTML` is not set');\n    }\n\n    this.resetUIState();\n    return this._opts.getStandaloneReportHTML();\n  }\n\n  /**\n   * Save json as a gist. Unimplemented in base UI features.\n   */\n  saveAsGist() {\n    // TODO ?\n    throw new Error('Cannot save as gist from base report');\n  }\n\n  _enableFireworks() {\n    const scoresContainer = this._dom.find('.lh-scores-container', this._dom.rootEl);\n    scoresContainer.classList.add('lh-score100');\n  }","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/report/renderer/report-ui-features.js#L149-L185","documentation":"Thrown by ReportUIFeatures.getReportHtml when the renderer options (this._opts) do not include a getStandaloneReportHTML callback. That callback is the only way the report can reproduce its own HTML (used by the 'copy HTML' / save-as-html tools). The base ReportUIFeatures does not supply a default; the viewer subclass ViewerUIFeatures injects it via its constructor callbacks.","triggerScenarios":"Constructing new ReportUIFeatures(dom) (or with opts lacking getStandaloneReportHTML) and then invoking getReportHtml(), e.g. through a tools-menu action that calls it. Using the base class directly instead of ViewerUIFeatures.","commonSituations":"Embedding the Lighthouse report renderer in a custom host that instantiates ReportUIFeatures but forgets to wire the standalone-HTML generator. Copying example code that assumed viewer-only features.","solutions":["Pass a getStandaloneReportHTML function in the opts/callbacks: new ReportUIFeatures(dom, { getStandaloneReportHTML: () => generateStandaloneHtml }).","Use ViewerUIFeatures instead of the base class — it requires and wires getStandaloneReportHTML for you.","If you don't need HTML export, hide/disable the UI controls that call getReportHtml."],"exampleFix":"// before\nconst features = new ReportUIFeatures(dom); // no opts\n\n// after\nconst features = new ReportUIFeatures(dom, {\n  getStandaloneReportHTML: () => ReportGenerator.generateReportHtml(lhr),\n});","handlingStrategy":"validation","validationCode":"const opts = {\n  getStandaloneReportHTML: typeof getStandaloneReportHTML === 'function'\n    ? getStandaloneReportHTML\n    : () => ReportGenerator.generateReportHtml(currentLhr),\n};\nconst features = new ReportUIFeatures(dom, opts);","typeGuard":"/** @param {LH.Renderer.Options} opts */\nfunction hasStandaloneHtml(opts) {\n  return typeof opts?.getStandaloneReportHTML === 'function';\n}","tryCatchPattern":"try {\n  features.getReportHtml();\n} catch (err) {\n  if (err.message === '`getStandaloneReportHTML` is not set') {\n    // wire the callback and retry, or disable the HTML-export control\n  } else throw err;\n}","preventionTips":["Always pass a getStandaloneReportHTML callback in the renderer opts.","Prefer ViewerUIFeatures, which requires and injects this callback.","If HTML export is not needed, hide the UI controls that call getReportHtml."],"tags":["report-ui-features","configuration","options","renderer"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}