{"record":{"id":"38f804c91f9d3029","repo":"garrytan/gstack","slug":"unknown-flag-args-i","errorCode":null,"errorMessage":"Unknown flag: ${args[i]}","messagePattern":"Unknown flag: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"browse/src/write-commands.ts","lineNumber":225,"sourceCode":"          let json: any;\n          try { json = JSON.parse(raw); }\n          catch (e: any) { throw new Error(`load-html: --from-file JSON parse failed: ${e.message}`); }\n          if (typeof json.html !== 'string') {\n            throw new Error('load-html: --from-file JSON must have a \"html\" string field');\n          }\n          if (json.waitUntil && json.waitUntil !== 'load'\n              && json.waitUntil !== 'domcontentloaded' && json.waitUntil !== 'networkidle') {\n            throw new Error(`load-html: --from-file waitUntil '${json.waitUntil}' invalid`);\n          }\n          fromFilePayload = { html: json.html, waitUntil: json.waitUntil };\n        } else if (args[i] === '--wait-until') {\n          const val = args[++i];\n          if (val !== 'load' && val !== 'domcontentloaded' && val !== 'networkidle') {\n            throw new Error(`Invalid --wait-until '${val}'. Must be one of: load, domcontentloaded, networkidle.`);\n          }\n          waitUntil = val;\n        } else if (args[i].startsWith('--')) {\n          throw new Error(`Unknown flag: ${args[i]}`);\n        } else if (!filePath) {\n          filePath = args[i];\n        }\n      }\n\n      // Inline HTML path: validate size + magic byte, then setContent directly.\n      if (fromFilePayload) {\n        const MAX_BYTES = parseInt(process.env.GSTACK_BROWSE_MAX_HTML_BYTES || '', 10) || (50 * 1024 * 1024);\n        if (Buffer.byteLength(fromFilePayload.html, 'utf8') > MAX_BYTES) {\n          throw new Error(\n            `load-html: --from-file html too large (> ${MAX_BYTES} bytes). ` +\n            '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        }","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L207-L243","documentation":"Unknown-flag guard at write-commands.ts:224-226. The argument loop only recognizes --from-file and --wait-until (tab-id is handled upstream by the dispatcher). Any other token starting with -- is rejected to surface typos rather than silently ignoring them.","triggerScenarios":"A misspelled or unsupported flag: --fromfile, --file, --wait, --url, --content, --source, --output.","commonSituations":"Typo in a flag name; using a flag from a different command; assuming an option exists because a sibling command has it.","solutions":["Use only the supported flags: --from-file <path> and --wait-until <value>","Check the usage string (thrown when no file path is given) for the full grammar","Correct the typo"],"exampleFix":"// before\nload-html --fromfile ./p.json\n// after\nload-html --from-file ./p.json","handlingStrategy":"validation","validationCode":"const KNOWN_FLAGS = new Set(['--from-file','--wait-until'])\nfunction onlyKnownFlags(args: string[]): boolean {\n  return args.every(a => !a.startsWith('--') || KNOWN_FLAGS.has(a))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only --from-file and --wait-until (tab-id is handled upstream)","Double-check flag spelling against the usage string","Validate the arg list in automation before invoking"],"tags":["usage","arguments","load-html","write-commands"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}