{"record":{"id":"3716adeecd78049b","repo":"wavetermdev/waveterm","slug":"error-making-jwt-token-w","errorCode":null,"errorMessage":"error making jwt token: %w","messagePattern":"error making jwt token: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/blockcontroller/durableshellcontroller.go","lineNumber":261,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"connection %q not found\", connName)\n\t}\n\tconnRoute := wshutil.MakeConnectionRouteId(connName)\n\tremoteInfo, err := wshclient.RemoteGetInfoCommand(wshclient.GetBareRpcClient(), &wshrpc.RpcOpts{Route: connRoute, Timeout: 2000})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to obtain remote info from connserver: %w\", err)\n\t}\n\tshellType := shellutil.GetShellTypeFromShellPath(remoteInfo.Shell)\n\tswapToken := makeSwapToken(ctx, ctx, dsc.BlockId, blockMeta, connName, shellType)\n\tsockName := wavebase.GetPersistentRemoteSockName(wstore.GetClientId())\n\trpcContext := wshrpc.RpcContext{\n\t\tProcRoute: true,\n\t\tSockName:  sockName,\n\t\tBlockId:   dsc.BlockId,\n\t\tConn:      connName,\n\t}\n\tjwtStr, err := wshutil.MakeClientJWTToken(rpcContext)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error making jwt token: %w\", err)\n\t}\n\tswapToken.RpcContext = &rpcContext\n\tswapToken.Env[wshutil.WaveJwtTokenVarName] = jwtStr\n\tcmdOpts := shellexec.CommandOptsType{\n\t\tInteractive: true,\n\t\tLogin:       true,\n\t\tCwd:         cwd,\n\t\tSwapToken:   swapToken,\n\t\tForceJwt:    blockMeta.GetBool(waveobj.MetaKey_CmdJwt, false),\n\t}\n\tjobId, err := shellexec.StartRemoteShellJob(ctx, ctx, termSize, cmdStr, cmdOpts, conn, dsc.BlockId)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to start durable shell: %w\", err)\n\t}\n\treturn jobId, nil\n}\n","sourceCodeStart":243,"sourceCodeEnd":278,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/blockcontroller/durableshellcontroller.go#L243-L278","documentation":"Before launching the remote shell, the controller mints a JWT token (wshutil.MakeClientJWTToken) that authenticates the spawned shell's wsh RPC back to the app, injected via the swap token environment. This error means local token generation failed — typically missing signing key material or malformed RpcContext.","triggerScenarios":"MakeClientJWTToken returns an error: the client's signing key/secret is missing or unreadable, or the constructed RpcContext (ProcRoute, SockName, BlockId, Conn) is invalid for token claims.","commonSituations":"Corrupted or missing local key/config files after a bad install or profile copy; running in a sandbox/home-dir without the expected wave config; clock/claims issues in extreme cases.","solutions":["Check that the local wave config directory and its key material exist and are readable.","Reset the app's key/config state (re-initialize config) if keys are corrupt.","Verify RpcContext fields (SockName, BlockId, Conn) are non-empty and correct.","Inspect the wrapped inner error for the exact crypto/token failure."],"exampleFix":"// before\nrpcContext := wshrpc.RpcContext{ProcRoute: true} // missing Route/fields, token gen fails\n// after\nrpcContext := wshrpc.RpcContext{ProcRoute: true, Route: connRoute, BlockId: dsc.BlockId, SockName: sockName, Conn: connName}\njwtStr, err := wshutil.MakeClientJWTToken(rpcContext)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := controller.Start(ctx, meta, rtOpts, false); err != nil {\n    if strings.Contains(err.Error(), \"jwt token\") {\n        // regenerate/repair local key material, then retry\n    }\n    return err\n}","preventionTips":["Do not hand-edit or copy partial wave config/key files between machines","Keep all RpcContext fields populated when constructing tokens","Back up and restore config directories atomically","Upgrade wsh and the app together to keep token formats compatible"],"tags":["jwt","auth","token","configuration"],"backgroundTag":"jwt-token-generation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}