{"record":{"id":"cdb8a17ba2f7842f","repo":"garrytan/gstack","slug":"load-html-absolutepath-is-not-a-regular-file","errorCode":null,"errorMessage":"load-html: ${absolutePath} is not a regular file.","messagePattern":"load-html: (.+?) is not a regular file\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":287,"sourceCode":"      }\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,\n      // <!-- comment, <?xml prolog — including bare HTML fragments like `<div>...</div>`\n      // which setContent wraps in a full document. Rejects binary files mis-renamed .html\n      // (first byte won't be `<`).","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L269-L305","documentation":"Error \"load-html: ${absolutePath} is not a regular file.\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:287 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"}