{"record":{"id":"0c06d4e86e422dc8","repo":"wavetermdev/waveterm","slug":"failed-to-start-job-w","errorCode":null,"errorMessage":"failed to start job: %w","messagePattern":"failed to start job: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jobmanager/jobmanager.go","lineNumber":241,"sourceCode":"\tjm.lock.Lock()\n\tdefer jm.lock.Unlock()\n\n\tif jm.Cmd != nil {\n\t\tlog.Printf(\"StartJob: job already started\")\n\t\treturn nil, fmt.Errorf(\"job already started\")\n\t}\n\n\tcmdDef := CmdDef{\n\t\tCmd:      data.Cmd,\n\t\tArgs:     data.Args,\n\t\tEnv:      data.Env,\n\t\tTermSize: data.TermSize,\n\t}\n\tlog.Printf(\"StartJob: creating job cmd for jobid=%s\", jm.JobId)\n\tjobCmd, err := MakeJobCmd(jm.JobId, cmdDef)\n\tif err != nil {\n\t\tlog.Printf(\"StartJob: failed to make job cmd: %v\", err)\n\t\treturn nil, fmt.Errorf(\"failed to start job: %w\", err)\n\t}\n\tjm.Cmd = jobCmd\n\tlog.Printf(\"StartJob: job cmd created successfully\")\n\n\tif data.StreamMeta != nil {\n\t\tserverSeq, err := jm.connectToStreamHelper_withlock(msc, *data.StreamMeta, 0)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to connect stream: %w\", err)\n\t\t}\n\t\terr = msc.WshRpc.StreamBroker.AttachStreamWriter(data.StreamMeta, jm.StreamManager)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to attach stream writer: %w\", err)\n\t\t}\n\t\tlog.Printf(\"StartJob: connected stream streamid=%s serverSeq=%d\\n\", data.StreamMeta.Id, serverSeq)\n\t}\n\n\tcmd, cmdPty := jobCmd.GetCmd()\n\tif cmdPty != nil {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/jobmanager/jobmanager.go#L223-L259","documentation":"StartJob builds the job's command via MakeJobCmd(jm.JobId, cmdDef). If command construction fails (invalid command definition, working directory, environment marshaling, or pty setup inputs), the failure is wrapped as 'failed to start job'. The job manager state (jm.Cmd) is left unset.","triggerScenarios":"CommandStartJobData with an empty/missing Cmd, unresolvable command name, invalid Env map or TermSize values that MakeJobCmd cannot translate into a valid exec.Cmd.","commonSituations":"Typo in the command name or command not on PATH at daemon time; empty cmd string from a UI submitting a blank form; environment variables containing values MakeJobCmd cannot serialize.","solutions":["Check the log line 'StartJob: failed to make job cmd' for the wrapped inner cause","Validate data.Cmd is a non-empty, resolvable command path and Args/Env are well-formed before calling StartJob","Use an absolute command path if the daemon's PATH differs from the user's shell PATH","If TermSize is supplied, ensure Width/Height are positive"],"exampleFix":"// before\nstartData := wshrpc.CommandStartJobData{Cmd: userTypedCmd}\n// after\nif userTypedCmd == \"\" {\n    return fmt.Errorf(\"cmd is required\")\n}\ncmdPath, err := exec.LookPath(userTypedCmd)\nif err != nil {\n    return fmt.Errorf(\"command %q not found: %w\", userTypedCmd, err)\n}\nstartData := wshrpc.CommandStartJobData{Cmd: cmdPath}","handlingStrategy":"validation","validationCode":"if data.Cmd == \"\" {\n    return fmt.Errorf(\"Cmd is required\")\n}\nif _, err := exec.LookPath(data.Cmd); err != nil {\n    return fmt.Errorf(\"Cmd %q not found on daemon PATH: %w\", data.Cmd, err)\n}\nif data.TermSize != nil && (data.TermSize.Rows <= 0 || data.TermSize.Cols <= 0) {\n    return fmt.Errorf(\"TermSize must be positive\")\n}","typeGuard":null,"tryCatchPattern":"rtn, err := jm.StartJob(msc, startData)\nif err != nil {\n    var inner error\n    if errors.Unwrap(err) != nil { inner = errors.Unwrap(err) }\n    log.Printf(\"start failed: %v (cause: %v)\", err, inner)\n    return err\n}","preventionTips":["Validate Cmd/Args/Env/TermSize before submitting StartJob","Use absolute command paths to avoid daemon PATH differences","Log MakeJobCmd's inner error (also in jm logs) for the real cause","Test job definitions with a dry-run LookPath check"],"tags":["process-start","exec","validation"],"backgroundTag":"command-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}