debug(mpc-system): 添加 joinToken 调试日志
- service-party-app: validateInviteCode 记录 token 长度 - service-party-app: joinSession 记录 token 信息 - service-party-app: 修复 ValidateInviteCodeResult 类型缺少 joinToken 字段 - session-coordinator: JoinSession 记录 token 解析详情 用于调试 "invalid token" 错误 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5f4c7c135f
commit
df8a14211e
|
|
@ -549,6 +549,8 @@ function setupIpcHandlers() {
|
||||||
// 加入会话
|
// 加入会话
|
||||||
ipcMain.handle('grpc:joinSession', async (_event, { sessionId, partyId, joinToken, walletName }) => {
|
ipcMain.handle('grpc:joinSession', async (_event, { sessionId, partyId, joinToken, walletName }) => {
|
||||||
try {
|
try {
|
||||||
|
debugLog.info('grpc', `Joining session: sessionId=${sessionId}, partyId=${partyId}, has_token=${!!joinToken}, token_length=${joinToken?.length || 0}`);
|
||||||
|
|
||||||
const result = await grpcClient?.joinSession(sessionId, partyId, joinToken);
|
const result = await grpcClient?.joinSession(sessionId, partyId, joinToken);
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
// 设置活跃的 keygen 会话信息
|
// 设置活跃的 keygen 会话信息
|
||||||
|
|
@ -686,7 +688,11 @@ function setupIpcHandlers() {
|
||||||
// gRPC - 验证邀请码 (通过 Account 服务 HTTP API)
|
// gRPC - 验证邀请码 (通过 Account 服务 HTTP API)
|
||||||
ipcMain.handle('grpc:validateInviteCode', async (_event, { code }) => {
|
ipcMain.handle('grpc:validateInviteCode', async (_event, { code }) => {
|
||||||
try {
|
try {
|
||||||
|
debugLog.info('account', `Validating invite code: ${code}`);
|
||||||
const result = await accountClient?.getSessionByInviteCode(code);
|
const result = await accountClient?.getSessionByInviteCode(code);
|
||||||
|
|
||||||
|
debugLog.info('account', `Got session for invite code: session_id=${result?.session_id}, has_join_token=${!!result?.join_token}, token_length=${result?.join_token?.length || 0}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
sessionInfo: {
|
sessionInfo: {
|
||||||
|
|
@ -703,6 +709,7 @@ function setupIpcHandlers() {
|
||||||
joinToken: result?.join_token,
|
joinToken: result?.join_token,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
debugLog.error('account', `Failed to validate invite code: ${(error as Error).message}`);
|
||||||
return { success: false, error: (error as Error).message };
|
return { success: false, error: (error as Error).message };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ interface JoinSessionResult {
|
||||||
interface ValidateInviteCodeResult {
|
interface ValidateInviteCodeResult {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
sessionInfo?: SessionInfo;
|
sessionInfo?: SessionInfo;
|
||||||
|
joinToken?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,27 @@ func (uc *JoinSessionUseCase) Execute(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
inputData input.JoinSessionInput,
|
inputData input.JoinSessionInput,
|
||||||
) (*input.JoinSessionOutput, error) {
|
) (*input.JoinSessionOutput, error) {
|
||||||
|
// Debug: log token info
|
||||||
|
tokenLen := len(inputData.JoinToken)
|
||||||
|
tokenPreview := ""
|
||||||
|
if tokenLen > 20 {
|
||||||
|
tokenPreview = inputData.JoinToken[:20] + "..."
|
||||||
|
} else if tokenLen > 0 {
|
||||||
|
tokenPreview = inputData.JoinToken
|
||||||
|
}
|
||||||
|
logger.Debug("JoinSession: parsing token",
|
||||||
|
zap.String("session_id", inputData.SessionID.String()),
|
||||||
|
zap.String("party_id", inputData.PartyID),
|
||||||
|
zap.Int("token_length", tokenLen),
|
||||||
|
zap.String("token_preview", tokenPreview))
|
||||||
|
|
||||||
// 1. Parse join token to extract session ID (in case not provided)
|
// 1. Parse join token to extract session ID (in case not provided)
|
||||||
claims, err := uc.tokenValidator.ParseJoinTokenClaims(inputData.JoinToken)
|
claims, err := uc.tokenValidator.ParseJoinTokenClaims(inputData.JoinToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error("JoinSession: failed to parse token",
|
||||||
|
zap.String("session_id", inputData.SessionID.String()),
|
||||||
|
zap.String("party_id", inputData.PartyID),
|
||||||
|
zap.Error(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue