{"record":{"id":"43057ffd7bb422e5","repo":"wavetermdev/waveterm","slug":"not-authenticated-to-server","errorCode":null,"errorMessage":"not authenticated to server","messagePattern":"not authenticated to server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jobmanager/mainserverconn.go","lineNumber":112,"sourceCode":"\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}\n\treturn WshCmdJobManager.StartStream(msc)\n}\n\nfunc (msc *MainServerConn) JobInputCommand(ctx context.Context, data wshrpc.CommandJobInputData) error {\n\tif !msc.PeerAuthenticated.Load() {\n\t\treturn fmt.Errorf(\"not authenticated\")\n\t}\n\tif !WshCmdJobManager.IsJobStarted() {\n\t\treturn fmt.Errorf(\"job not started\")\n\t}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/jobmanager/mainserverconn.go#L94-L130","documentation":"Second check in JobPrepareConnectCommand: the peer is authenticated, but this job manager process itself has not yet authenticated to the main server (SelfAuthenticated false, set only after authenticateSelfToServer succeeds). The connection is not fully two-way authenticated, so PrepareConnect is refused.","triggerScenarios":"JobPrepareConnectCommand called when PeerAuthenticated is true but SelfAuthenticated is false — e.g. authenticateSelfToServer failed or was never invoked during the handshake.","commonSituations":"Peer auth succeeded but the self-auth RPC to the server errored (network, wrong jobAuthToken), or a partially completed handshake after a transient failure.","solutions":["Ensure authenticateSelfToServer ran and succeeded; check its logs for 'failed to authenticate to server'.","Retry the full AuthenticateToJobManagerCommand flow, which performs both peer and self authentication.","Fix underlying self-auth causes (jobAuthToken validity, server reachability) then reconnect."],"exampleFix":"// before\n// peer auth done, self auth skipped/failed\nconn.JobPrepareConnectCommand(ctx, prepData)\n// after\nif err := msc.authenticateSelfToServer(jobAuthToken); err != nil {\n    return fmt.Errorf(\"self auth required before PrepareConnect: %w\", err)\n}\nrtn, err := conn.JobPrepareConnectCommand(ctx, prepData)","handlingStrategy":"try-catch","validationCode":"if !conn.selfAuthenticated() {\n    return fmt.Errorf(\"self-auth to server incomplete; rerun the auth handshake\")\n}","typeGuard":null,"tryCatchPattern":"rtn, err := conn.JobPrepareConnectCommand(ctx, data)\nif err != nil {\n    if err.Error() == \"not authenticated to server\" {\n        if authErr := conn.AuthenticateToJobManagerCommand(ctx, authData); authErr != nil {\n            return fmt.Errorf(\"self auth failed: %w\", authErr)\n        }\n        rtn, err = conn.JobPrepareConnectCommand(ctx, data)\n    }\n    if err != nil { return err }\n}","preventionTips":["Always use the full AuthenticateToJobManagerCommand flow (it does both peer and self auth)","Verify self-auth logs after transient network failures and retry","Treat half-completed handshakes as failed and restart the sequence"],"tags":["authentication","rpc","jobmanager","handshake"],"backgroundTag":"not-authenticated","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}