{"record":{"id":"5e7f765da25af687","repo":"garrytan/gstack","slug":"invalid-wait-until-val-must-be-one-of-loa","errorCode":null,"errorMessage":"Invalid --wait-until '${val}'. Must be one of: load, domcontentloaded, networkidle.","messagePattern":"Invalid --wait-until '(.+?)'\\. Must be one of: load, domcontentloaded, networkidle\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":221,"sourceCode":"              `load-html: --from-file ${payloadPath} must be under ${SAFE_DIRECTORIES.join(' or ')} (security policy). Copy the payload into the project tree or /tmp first.`\n            );\n          }\n          const raw = fs.readFileSync(payloadPath, 'utf8');\n          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        }","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L203-L239","documentation":"CLI-flag validation at write-commands.ts:219-222. The --wait-until flag (distinct from the JSON payload's waitUntil) got a value that is not load, domcontentloaded, or networkidle. This is the command-line form of the same constraint.","triggerScenarios":"Invoking load-html --wait-until <bad> <file>, e.g. --wait-until none, --wait-until idle, --wait-until ready.","commonSituations":"Typing a value from a different framework's API; autocomplete inserting the wrong token; copy-paste from Playwright page.goto docs that list extra strategies.","solutions":["Use one of: load, domcontentloaded, networkidle","Drop the flag to use the default (domcontentloaded)"],"exampleFix":"// before\nload-html page.html --wait-until none\n// after\nload-html page.html --wait-until networkidle","handlingStrategy":"validation","validationCode":"const WAIT_UNTIL = new Set(['load','domcontentloaded','networkidle'])\nfunction validCliWaitUntil(v: string): boolean {\n  return WAIT_UNTIL.has(v)\n}","typeGuard":"function isCliWaitUntil(v: string): v is 'load'|'domcontentloaded'|'networkidle' {\n  return ['load','domcontentloaded','networkidle'].includes(v)\n}","tryCatchPattern":null,"preventionTips":["Drop the flag to use the default (domcontentloaded)","Cross-check the value against the usage string","Avoid values from other frameworks' APIs"],"tags":["load-html","waituntil","validation","arguments","write-commands"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}