{"record":{"id":"c07c0a0b33cfb7ae","repo":"wavetermdev/waveterm","slug":"no-token-in-authenticatetoken-message","errorCode":null,"errorMessage":"no token in authenticatetoken message","messagePattern":"no token in authenticatetoken message","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshutil/wshrouter_controlimpl.go","lineNumber":152,"sourceCode":"\t}\n\trouteId := entry.RpcContext.GenerateRouteId()\n\tif routeId == \"\" {\n\t\treturn wshrpc.CommandAuthenticateRtnData{}, fmt.Errorf(\"no routeid\")\n\t}\n\treturn wshrpc.CommandAuthenticateRtnData{\n\t\tRouteId:        routeId,\n\t\tEnv:            entry.Env,\n\t\tInitScriptText: entry.ScriptText,\n\t\tRpcContext:     entry.RpcContext,\n\t}, nil\n}\n\nfunc (impl *WshRouterControlImpl) AuthenticateTokenVerifyCommand(ctx context.Context, data wshrpc.CommandAuthenticateTokenData) (wshrpc.CommandAuthenticateRtnData, error) {\n\tif !impl.Router.IsRootRouter() {\n\t\treturn wshrpc.CommandAuthenticateRtnData{}, fmt.Errorf(\"authenticatetokenverify can only be called on root router\")\n\t}\n\tif data.Token == \"\" {\n\t\treturn wshrpc.CommandAuthenticateRtnData{}, fmt.Errorf(\"no token in authenticatetoken message\")\n\t}\n\n\trtnData, err := extractTokenData(data.Token)\n\tif err != nil {\n\t\tlog.Printf(\"wshrouter authenticate-token-verify error: %v\", err)\n\t\treturn wshrpc.CommandAuthenticateRtnData{}, err\n\t}\n\n\tlog.Printf(\"wshrouter authenticate-token-verify success routeid=%q\", rtnData.RouteId)\n\treturn rtnData, nil\n}\n\nfunc (impl *WshRouterControlImpl) AuthenticateTokenCommand(ctx context.Context, data wshrpc.CommandAuthenticateTokenData) (wshrpc.CommandAuthenticateRtnData, error) {\n\thandler := GetRpcResponseHandlerFromContext(ctx)\n\tif handler == nil {\n\t\treturn wshrpc.CommandAuthenticateRtnData{}, fmt.Errorf(\"no response handler in context\")\n\t}\n\tlinkId := handler.GetIngressLinkId()","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshutil/wshrouter_controlimpl.go#L134-L170","documentation":"AuthenticateTokenVerifyCommand requires data.Token to be a non-empty string before it will attempt verification. An empty Token field in CommandAuthenticateTokenData is rejected immediately with this message.","triggerScenarios":"Calling AuthenticateTokenVerifyCommand with wshrpc.CommandAuthenticateTokenData{Token: \"\"} — typically the token variable was never populated before the RPC was sent.","commonSituations":"Env var holding the token not set when constructing the request; a code path that reads the token asynchronously and races ahead with an empty value; copy/paste loss when scripting wsh connections.","solutions":["Check the token source (env var, file, CLI flag) and confirm it was populated before building CommandAuthenticateTokenData.","Add a client-side empty-string guard before sending the RPC.","Re-run the token issuance step if the token was never minted."],"exampleFix":"// before\ndata := wshrpc.CommandAuthenticateTokenData{Token: tokenFromEnv} // tokenFromEnv == \"\"\n// after\nif tokenFromEnv == \"\" {\n    return fmt.Errorf(\"connection token is empty; re-run token issuance\")\n}\ndata := wshrpc.CommandAuthenticateTokenData{Token: tokenFromEnv}","handlingStrategy":"validation","validationCode":"if data.Token == \"\" {\n    return fmt.Errorf(\"token must be non-empty before calling authenticatetokenverify\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the token source (env/file/flag) before constructing the request","Fail fast at process startup if the connection token is missing","Log (without leaking) token length to confirm provisioning worked"],"tags":["auth","validation","empty-input","rpc"],"backgroundTag":"missing-auth-token","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}