{"record":{"id":"71836b7f3590403a","repo":"wavetermdev/waveterm","slug":"not-authenticated","errorCode":null,"errorMessage":"not authenticated","messagePattern":"not authenticated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jobmanager/mainserverconn.go","lineNumber":102,"sourceCode":"\t}\n\tmsc.PeerAuthenticated.Store(true)\n\tlog.Printf(\"AuthenticateToJobManager: authentication successful for JobId=%s\\n\", claims.JobId)\n\n\terr = msc.authenticateSelfToServer(jobAuthToken)\n\tif err != nil {\n\t\tmsc.PeerAuthenticated.Store(false)\n\t\treturn err\n\t}\n\n\tWshCmdJobManager.SetAttachedClient(msc)\n\treturn nil\n}\n\nfunc (msc *MainServerConn) StartJobCommand(ctx context.Context, data wshrpc.CommandStartJobData) (*wshrpc.CommandStartJobRtnData, error) {\n\tlog.Printf(\"StartJobCommand: received command=%s args=%v\", data.Cmd, data.Args)\n\tif !msc.PeerAuthenticated.Load() {\n\t\tlog.Printf(\"StartJobCommand: not authenticated\")\n\t\treturn nil, fmt.Errorf(\"not authenticated\")\n\t}\n\treturn WshCmdJobManager.StartJob(msc, data)\n}\n\nfunc (msc *MainServerConn) JobPrepareConnectCommand(ctx context.Context, data wshrpc.CommandJobPrepareConnectData) (*wshrpc.CommandJobConnectRtnData, error) {\n\tif !msc.PeerAuthenticated.Load() {\n\t\treturn nil, fmt.Errorf(\"peer not authenticated\")\n\t}\n\tif !msc.SelfAuthenticated.Load() {\n\t\treturn nil, fmt.Errorf(\"not authenticated to server\")\n\t}\n\treturn WshCmdJobManager.PrepareConnect(msc, data)\n}\n\nfunc (msc *MainServerConn) JobStartStreamCommand(ctx context.Context, data wshrpc.CommandJobStartStreamData) error {\n\tif !msc.PeerAuthenticated.Load() {\n\t\treturn fmt.Errorf(\"not authenticated\")\n\t}","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/jobmanager/mainserverconn.go#L84-L120","documentation":"StartJobCommand is an RPC handler that requires the connecting peer to have completed authentication (PeerAuthenticated). If the peer never called (or failed) AuthenticateToJobManagerCommand, the handler refuses with this sentinel error before delegating to the job manager.","triggerScenarios":"Calling StartJob over the WSH control route on a MainServerConn whose PeerAuthenticated atomic flag is still false — i.e. commands sent before or without successful peer authentication.","commonSituations":"Client code issuing job commands immediately after connect without awaiting authentication, authentication failing earlier (expired token, claim mismatch), or reconnecting without re-authenticating.","solutions":["Call AuthenticateToJobManagerCommand successfully before invoking StartJobCommand.","Check earlier authentication errors (token expiry/claims) and fix them, then re-authenticate.","Ensure ordering in client code: await auth completion (SelfAuthenticated/PeerAuthenticated) before sending job commands."],"exampleFix":"// before\nconn.StartJobCommand(ctx, data) // may fail: not authenticated\n// after\nif err := conn.AuthenticateToJobManagerCommand(ctx, authData); err != nil {\n    return err\n}\nrtn, err := conn.StartJobCommand(ctx, data)","handlingStrategy":"try-catch","validationCode":"if !conn.peerAuthenticated() {\n    return fmt.Errorf(\"authenticate before calling StartJob\")\n}","typeGuard":null,"tryCatchPattern":"rtn, err := conn.StartJobCommand(ctx, data)\nif err != nil {\n    if err.Error() == \"not authenticated\" {\n        if authErr := conn.AuthenticateToJobManagerCommand(ctx, authData); authErr != nil {\n            return authErr\n        }\n        rtn, err = conn.StartJobCommand(ctx, data)\n    }\n    if err != nil { return err }\n}","preventionTips":["Establish the auth handshake immediately after connecting","Await authentication completion before sending job commands","Re-authenticate after any reconnect"],"tags":["authentication","rpc","jobmanager","authorization"],"backgroundTag":"not-authenticated","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}