{"record":{"id":"12db07a274ac0571","repo":"garrytan/gstack","slug":"load-html-absolutepath-is-a-directory-not-a-f","errorCode":null,"errorMessage":"load-html: ${absolutePath} is a directory, not a file. Pass a .html file.","messagePattern":"load-html: (.+?) is a directory, not a file\\. Pass a \\.html file\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":284,"sourceCode":"        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 {\n        stat = await fs.promises.stat(absolutePath);\n      } catch (e: any) {\n        if (e.code === 'ENOENT') {\n          throw new Error(\n            `load-html: file not found at ${absolutePath}. Check spelling or copy the file under ${process.cwd()} or ${TEMP_DIR}.`\n          );\n        }\n        throw e;\n      }\n      if (stat.isDirectory()) {\n        throw new Error(`load-html: ${absolutePath} is a directory, not a file. Pass a .html file.`);\n      }\n      if (!stat.isFile()) {\n        throw new Error(`load-html: ${absolutePath} is not a regular file.`);\n      }\n\n      // Size cap\n      const MAX_BYTES = parseInt(process.env.GSTACK_BROWSE_MAX_HTML_BYTES || '', 10) || (50 * 1024 * 1024);\n      if (stat.size > MAX_BYTES) {\n        throw new Error(\n          `load-html: file too large (${stat.size} bytes > ${MAX_BYTES} cap). Raise with GSTACK_BROWSE_MAX_HTML_BYTES=<N> or split the HTML.`\n        );\n      }\n\n      // Single read: Buffer → magic-byte peek → utf-8 string\n      const buf = await fs.promises.readFile(absolutePath);\n\n      // Magic-byte check: strip UTF-8 BOM + leading whitespace, then verify the first\n      // non-whitespace byte starts a markup construct. Accepts any <tag, <!doctype,","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L266-L302","documentation":"Error \"load-html: ${absolutePath} is a directory, not a file. Pass a .html file.\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:284 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"}