{"record":{"id":"91b6b90649e192a4","repo":"garrytan/gstack","slug":"load-html-file-does-not-appear-to-be-html-expect","errorCode":null,"errorMessage":"load-html: file does not appear to be HTML. Expected .html/.htm/.xhtml/.svg, got ${ext || '(no extension)'}. Rename the file if it's really HTML.","messagePattern":"load-html: file does not appear to be HTML\\. Expected \\.html/\\.htm/\\.xhtml/\\.svg, got (.+?)\\. Rename the file if it's really HTML\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":255,"sourceCode":"            'Raise with GSTACK_BROWSE_MAX_HTML_BYTES=<N>.'\n          );\n        }\n        const peek = fromFilePayload.html.trimStart();\n        if (!/^<[a-zA-Z!?]/.test(peek)) {\n          throw new Error('load-html: --from-file html does not start with a valid markup opener');\n        }\n        const finalWaitUntil = fromFilePayload.waitUntil ?? waitUntil;\n        await session.setTabContent(fromFilePayload.html, { waitUntil: finalWaitUntil });\n        return `Loaded HTML: (inline from --from-file, ${fromFilePayload.html.length} chars)`;\n      }\n\n      if (!filePath) throw new Error('Usage: browse load-html <file> [--wait-until load|domcontentloaded|networkidle] [--tab-id <N>]  |  load-html --from-file <payload.json> [--tab-id <N>]');\n\n      // Extension allowlist\n      const ALLOWED_EXT = ['.html', '.htm', '.xhtml', '.svg'];\n      const ext = path.extname(filePath).toLowerCase();\n      if (!ALLOWED_EXT.includes(ext)) {\n        throw new Error(\n          `load-html: file does not appear to be HTML. Expected .html/.htm/.xhtml/.svg, got ${ext || '(no extension)'}. Rename the file if it's really HTML.`\n        );\n      }\n\n      const absolutePath = path.resolve(filePath);\n\n      // Safe-dirs check (reuses canonical read-side policy)\n      try {\n        validateReadPath(absolutePath);\n      } catch (e: any) {\n        throw new Error(\n          `load-html: ${absolutePath} must be under ${SAFE_DIRECTORIES.join(' or ')} (security policy). Copy the file into the project tree or /tmp first.`\n        );\n      }\n\n      // stat check — reject non-file targets with actionable error\n      let stat: fs.Stats;\n      try {","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L237-L273","documentation":"Error \"load-html: file does not appear to be HTML. Expected .html/.htm/.xhtml/.svg, got ${ext || '(no extension)'}. Rename the file if it's really HTML.\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:255 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}