{"record":{"id":"9b87080428072f38","repo":"heygen-com/hyperframes","slug":"unknown-context-field-invalid-length-1","errorCode":null,"errorMessage":"Unknown context field${invalid.length === 1 ? \"\" : \"s\"}: ${invalid.join(\", \")}","messagePattern":"Unknown context field(.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/preview.ts","lineNumber":491,"sourceCode":"  return {\n    port: server.port,\n    projectName: server.projectName,\n    projectDir: server.projectDir,\n    url: previewBaseUrl(server.port, server.host),\n  };\n}\n\nfunction parseContextFields(value: string | undefined): ContextField[] {\n  if (value === undefined) return DEFAULT_CONTEXT_FIELDS;\n  if (!value.trim()) throw new Error(\"--context-fields cannot be empty\");\n  const allowed = new Set<ContextField>(DEFAULT_CONTEXT_FIELDS);\n  const fields = value\n    .split(\",\")\n    .map((field) => field.trim())\n    .filter(Boolean);\n  const invalid = fields.filter((field) => !allowed.has(field as ContextField));\n  if (invalid.length > 0) {\n    throw new Error(\n      `Unknown context field${invalid.length === 1 ? \"\" : \"s\"}: ${invalid.join(\", \")}`,\n    );\n  }\n  return [...new Set(fields)] as ContextField[];\n}\n\nfunction contextIncludes(fields: ContextField[], field: ContextField): boolean {\n  return fields.includes(field);\n}\n\nfunction addContextError(\n  payload: Record<string, unknown>,\n  field: ContextField,\n  error: { code: string; message: string },\n): void {\n  payload.errors = {\n    ...((payload.errors as Record<string, unknown> | undefined) ?? {}),\n    [field]: error,","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/commands/preview.ts#L473-L509","documentation":"Thrown by parseContextFields when one or more comma-separated values in --context-fields are not in the allowed set {server, selection, lint, capabilities}. The invalid entries are echoed back along with the count-aware 'field/fields' phrasing so the user knows exactly what to correct.","triggerScenarios":"Calling `hyperframes preview --context-fields foo` or `--context-fields server,foobar`. Each split+trimmed token is checked against the Set built from DEFAULT_CONTEXT_FIELDS; any token not present lands in `invalid` and triggers the throw at preview.ts:491.","commonSituations":"Typos (e.g. 'capabilties'), stale field names from an older CLI version, copying a field list from docs for a different release, or an agent guessing field names.","solutions":["Use only valid fields: `--context-fields server,selection,lint,capabilities`","Check the allowed set in packages/cli/src/commands/preview.ts:110 for your CLI version","Upgrade the CLI if you expected a field that exists in newer docs"],"exampleFix":"// before\nhyperframes preview --context-fields server,foo\n// after\nhyperframes preview --context-fields server,lint","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set([\"server\", \"selection\", \"lint\", \"capabilities\"]);\nfunction validContextFields(v: string): string[] {\n  const fields = v.split(\",\").map((s) => s.trim()).filter(Boolean);\n  const bad = fields.filter((f) => !ALLOWED.has(f));\n  if (bad.length) throw new Error(`Invalid context fields: ${bad.join(\", \")}`);\n  return fields;\n}","typeGuard":"function isContextField(v: string): v is \"server\" | \"selection\" | \"lint\" | \"capabilities\" {\n  return v === \"server\" || v === \"selection\" || v === \"lint\" || v === \"capabilities\";\n}","tryCatchPattern":null,"preventionTips":["Source field names from the CLI's DEFAULT_CONTEXT_FIELDS for your version","Treat typos as a build-time check in wrapper scripts","Upgrade the CLI before relying on newly documented fields"],"tags":["cli-input","preview","argument-validation"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}