{"record":{"id":"3998d59611c4af6c","repo":"wavetermdev/waveterm","slug":"error-parsing-command-map-w","errorCode":null,"errorMessage":"error parsing command map: %w","messagePattern":"error parsing command map: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/service/service.go","lineNumber":108,"sourceCode":"\tnativeArgVal := reflect.New(argType)\n\terr := utilfn.DoMapStructure(nativeArgVal.Interface(), jsonArg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn nativeArgVal.Elem().Interface(), nil\n}\n\nfunc isSpecialWaveArgType(argType reflect.Type) bool {\n\treturn argType == waveObjRType || argType == waveObjSliceRType || argType == waveObjMapRType || argType == wsCommandRType\n}\n\nfunc convertWSCommand(argType reflect.Type, jsonArg any) (any, error) {\n\tif _, ok := jsonArg.(map[string]any); !ok {\n\t\treturn nil, fmt.Errorf(\"cannot convert %T to %s\", jsonArg, argType)\n\t}\n\tcmd, err := webcmd.ParseWSCommandMap(jsonArg.(map[string]any))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing command map: %w\", err)\n\t}\n\treturn cmd, nil\n}\n\nfunc convertSpecial(argType reflect.Type, jsonArg any) (any, error) {\n\tjsonType := reflect.TypeOf(jsonArg)\n\tif argType == orefRType {\n\t\tif jsonType.Kind() != reflect.String {\n\t\t\treturn nil, fmt.Errorf(\"cannot convert %T to %s\", jsonArg, argType)\n\t\t}\n\t\toref, err := waveobj.ParseORef(jsonArg.(string))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid oref string: %v\", err)\n\t\t}\n\t\treturn oref, nil\n\t} else if argType == wsCommandRType {\n\t\treturn convertWSCommand(argType, jsonArg)\n\t} else if argType == waveObjRType {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/service/service.go#L90-L126","documentation":"convertWSCommand found a map-shaped argument, but webcmd.ParseWSCommandMap rejected its contents - the map does not parse into a valid WSCommand. The %w-wrapped cause explains what was missing or invalid.","triggerScenarios":"The JSON map passed for a WSCommand parameter lacks the required 'command' field, has wrong-typed fields, or otherwise violates ParseWSCommandMap's expected structure.","commonSituations":"Hand-rolled RPC calls with misspelled keys ('cmd' instead of 'command'); partial command objects after JSON round-trips dropped fields; version mismatch on expected fields.","solutions":["Read the wrapped cause to see which field failed validation.","Ensure the map includes the required fields ParseWSCommandMap expects (typically a non-empty 'command' string).","Construct the command via the SDK's WSCommand type and serialize it instead of hand-building the map."],"exampleFix":"// before\nmap[string]any{\"cmd\": \"run\", \"args\": []any{\"ls\"}}\n// after\nmap[string]any{\"command\": \"run\", \"args\": []any{\"ls\"}}","handlingStrategy":"validation","validationCode":"cmdMap, _ := arg.(map[string]any)\nif name, _ := cmdMap[\"command\"].(string); name == \"\" {\n    return fmt.Errorf(\"WSCommand requires a non-empty 'command' field\")\n}","typeGuard":null,"tryCatchPattern":"cmd, err := webcmd.ParseWSCommandMap(m)\nif err != nil {\n    return fmt.Errorf(\"invalid command payload: %w\", err)\n}","preventionTips":["Use typed WSCommand constructors instead of raw maps.","Validate 'command' and required fields on the client before sending.","Version-check protocol shapes between frontend and backend."],"tags":["wscommand","validation","rpc","wrapped-error"],"backgroundTag":"schema-validation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}