{"record":{"id":"793f01a90fdecd2a","repo":"wavetermdev/waveterm","slug":"invalid-command-type-commandtype","errorCode":null,"errorMessage":"Invalid command type: ${commandType}","messagePattern":"Invalid command type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/util/ijson.ts","lineNumber":248,"sourceCode":"    if (commandType == null) {\n        throw new Error(\"Invalid command (no type): \" + command);\n    }\n    const path = getCommandPath(command);\n    if (!checkPath(path)) {\n        throw new Error(\"Invalid command path: \" + formatPath(path));\n    }\n    switch (commandType) {\n        case \"set\":\n            return setPath(data, path, command.value, null);\n\n        case \"del\":\n            return setPath(data, path, null, { remove: true });\n\n        case \"append\":\n            return setPath(data, path, command.value, { combinefn: combineFn_arrayAppend });\n\n        default:\n            throw new Error(\"Invalid command type: \" + commandType);\n    }\n}\n\nexport { applyCommand, combineFn_arrayAppend, getPath, setPath };\nexport type { PathType, SetPathOpts };\n","sourceCodeStart":230,"sourceCodeEnd":254,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/frontend/util/ijson.ts#L230-L254","documentation":"applyCommand only supports the command types \"set\", \"del\", and \"append\". Any other value falls through to the default branch and throws this error, since there is no handler for the requested mutation.","triggerScenarios":"Passing a command with type set to anything other than set/del/append — e.g. a typo ({type:'remove'}), a type from a newer/older protocol version, or a type field that is undefined/null and got stringified oddly before the earlier null check.","commonSituations":"Protocol drift between producer and consumer of commands (one side added 'insert', the other not upgraded), typos in hand-written command literals, or JSON round-trips that altered/renamed the type field.","solutions":["Print command.type and compare against the supported set: \"set\", \"del\", \"append\".","Fix the typo or use a supported command type.","Align versions: ensure the code generating commands and the code applying them agree on the command vocabulary.","Add an exhaustive union type (e.g. IJsonCommand = SetCmd|DelCmd|AppendCmd) so TS rejects unknown types at compile time."],"exampleFix":"// before\napplyCommand(data, { type: \"remove\", path: \"a.b\" });\n// after\napplyCommand(data, { type: \"del\", path: \"a.b\" });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"set\", \"del\", \"append\"]);\nif (!SUPPORTED.has(cmd?.type)) throw new Error(`unsupported ijson command type: ${cmd?.type}`);\napplyCommand(data, cmd);","typeGuard":"type IJsonCommandType = \"set\" | \"del\" | \"append\";\nfunction isIJsonCommandType(t: unknown): t is IJsonCommandType {\n  return t === \"set\" || t === \"del\" || t === \"append\";\n}","tryCatchPattern":"try {\n  applyCommand(data, cmd);\n} catch (e) {\n  if (String(e.message).startsWith(\"Invalid command type\")) {\n    console.error(\"unknown command type, dropping:\", cmd.type);\n    return;\n  }\n  throw e;\n}","preventionTips":["Type commands as a discriminated union keyed on the supported type literals.","Keep producer and consumer of command types in the same shared module/package version.","Handle unknown types at deserialize time (filter or map to supported types) instead of at apply time."],"tags":["ijson","command-type","invalid-argument"],"backgroundTag":"unsupported-command-type","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}