{"record":{"id":"f1dcf8d9911e260e","repo":"yikart/AiToEarn","slug":"no-response-from-gemini","errorCode":null,"errorMessage":"No response from Gemini","messagePattern":"No response from Gemini","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/agent/mcp/subtitle.mcp.ts","lineNumber":177,"sourceCode":"            parts: [\n              {\n                inlineData: {\n                  mimeType: 'audio/aac',\n                  data: audioBuffer.toString('base64'),\n                },\n              },\n              { text: prompt },\n            ],\n          }],\n          config: {\n            responseMimeType: 'application/json',\n          },\n        })\n\n        // Step 4: 解析响应\n        const responseText = response.text\n        if (!responseText) {\n          throw new Error('No response from Gemini')\n        }\n\n        const subtitleData = JSON.parse(responseText) as { entries: SubtitleEntry[] }\n        if (!subtitleData.entries || subtitleData.entries.length === 0) {\n          throw new Error('No subtitle entries in response')\n        }\n\n        this.logger.debug({ entryCount: subtitleData.entries.length }, 'Subtitle entries parsed')\n\n        // Step 5: 生成 SRT 格式\n        const srtContent = this.generateSrtFromEntries(subtitleData.entries)\n\n        // Step 6: 上传 SRT 文件\n        this.logger.debug('Uploading SRT file')\n        const srtBuffer = Buffer.from(srtContent, 'utf-8')\n        const result = await this.assetsService.uploadFromBuffer(userId, srtBuffer, {\n          type: AssetType.Subtitle,\n          mimeType: 'text/plain',","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/agent/mcp/subtitle.mcp.ts#L159-L195","documentation":"This BadRequestException is thrown by handleAuthCallback in TiktokController when the TikTok OAuth callback processing fails. The handler exchanges the authorization code with TikTok's API, and any error returned by that upstream HTTP call (or local failure) is caught, logged, and rethrown as a 400 with TikTok's error message when available. It is a wrapper that surfaces the upstream OAuth failure to the caller.","triggerScenarios":"GET on the TikTok auth callback route where the code exchange fails: invalid or expired authorization code, TikTok API returning an error payload (error.response.data.error.message), network failure to TikTok, or misconfigured client_key/client_secret.","commonSituations":"Developer redirects users to TikTok OAuth with a wrong redirect_uri registered in the TikTok developer console, uses sandbox credentials in production, the user denies permission, or the code was already consumed on a previous callback.","solutions":["Read the message appended by the handler — it contains TikTok's upstream error.message; fix the OAuth params it points to (redirect_uri, client_key, code).","Verify client_key/client_secret and redirect_uri in the TikTok developer app match the environment (sandbox vs production).","Ensure each authorization code is used exactly once and immediately after redirect.","Check server network access to open.tiktok.com and inspect the console.error log for error.response.data details."],"exampleFix":"// before: raw rethrow hides upstream detail\nthrow new BadRequestException(`处理授权回调失败: ${error.response?.data?.error?.message || error.message}`);\n// after: distinguish upstream OAuth errors from local failures\nconst upstream = error.response?.data?.error?.message;\nif (upstream) {\n  throw new BadRequestException(`TikTok OAuth失败: ${upstream}`);\n}\nthrow new BadRequestException(`处理授权回调失败: ${error.message}`);","handlingStrategy":"try-catch","validationCode":"if (!authCode) throw new Error('缺少授权code，请重新发起TikTok授权');\nif (!redirectUri) throw new Error('redirect_uri未配置');","typeGuard":null,"tryCatchPattern":"try {\n  await api.get('/plat/tiktok/auth/callback', { params: { code, state } });\n} catch (e) {\n  const msg = e.response?.data?.message || e.message;\n  if (/OAuth|redirect_uri|client_key/i.test(msg)) {\n    // 重新发起授权流程，检查开发者后台配置\n    restartOAuthFlow();\n  } else {\n    throw e;\n  }\n}","preventionTips":["Keep client_key/client_secret/redirect_uri in environment config matching sandbox vs production","Never reuse an authorization code; always start a fresh OAuth redirect","Log error.response.data on failure to see TikTok's upstream error_code"],"tags":["oauth","tiktok","auth-callback","bad-request"],"backgroundTag":"oauth-callback-failed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}