yikart/AiToEarn · error · Error
No response from Gemini
Error message
No response from Gemini
What it means
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.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-ai/src/core/agent/mcp/subtitle.mcp.ts:177
parts: [
{
inlineData: {
mimeType: 'audio/aac',
data: audioBuffer.toString('base64'),
},
},
{ text: prompt },
],
}],
config: {
responseMimeType: 'application/json',
},
})
// Step 4: 解析响应
const responseText = response.text
if (!responseText) {
throw new Error('No response from Gemini')
}
const subtitleData = JSON.parse(responseText) as { entries: SubtitleEntry[] }
if (!subtitleData.entries || subtitleData.entries.length === 0) {
throw new Error('No subtitle entries in response')
}
this.logger.debug({ entryCount: subtitleData.entries.length }, 'Subtitle entries parsed')
// Step 5: 生成 SRT 格式
const srtContent = this.generateSrtFromEntries(subtitleData.entries)
// Step 6: 上传 SRT 文件
this.logger.debug('Uploading SRT file')
const srtBuffer = Buffer.from(srtContent, 'utf-8')
const result = await this.assetsService.uploadFromBuffer(userId, srtBuffer, {
type: AssetType.Subtitle,
mimeType: 'text/plain',View on GitHub (pinned to d3aa8bea5b)
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.
Example fix
// before: raw rethrow hides upstream detail
throw new BadRequestException(`处理授权回调失败: ${error.response?.data?.error?.message || error.message}`);
// after: distinguish upstream OAuth errors from local failures
const upstream = error.response?.data?.error?.message;
if (upstream) {
throw new BadRequestException(`TikTok OAuth失败: ${upstream}`);
}
throw new BadRequestException(`处理授权回调失败: ${error.message}`); Defensive patterns
Strategy: try-catch
Validate before calling
if (!authCode) throw new Error('缺少授权code,请重新发起TikTok授权');
if (!redirectUri) throw new Error('redirect_uri未配置'); Try / catch
try {
await api.get('/plat/tiktok/auth/callback', { params: { code, state } });
} catch (e) {
const msg = e.response?.data?.message || e.message;
if (/OAuth|redirect_uri|client_key/i.test(msg)) {
// 重新发起授权流程,检查开发者后台配置
restartOAuthFlow();
} else {
throw e;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/f1dcf8d9911e260e.
Report an issue: GitHub.