yikart/AiToEarn · error · Error
获取TraceKey失败,失败原因:
Error message
获取TraceKey失败,失败原因:
What it means
getPublishTraceKey calls the Shipinhao (WeChat Channels) remote API to obtain a publish trace key. If the response errCode is non-zero, the service throws with the server-provided errMsg (or '未知'). It signals the server rejected the trace-key request, usually because of invalid cookies, account state, or device fingerprint issues.
Source
Thrown at project/aitoearn-electron/electron/plat/shipinhao/index.ts:596
scene: 7,
};
const res = await this.makeRequest(
this.getPublishTraceKeyUrl,
{
method: 'POST',
headers: {
Cookie: cookieString,
},
body: requestParams,
},
proxy,
);
if (res.errCode === 0) {
return res.data.traceKey;
} else {
throw new Error('获取TraceKey失败,失败原因:' + (res.errMsg ?? '未知'));
}
}
/**
* 获取发布上传参数
* @param cookieString
* @param proxy
*/
private async getPublishUploadParams(
cookieString: string,
proxy: string,
): Promise<any> {
const requestParams = {
reqScene: 7,
scene: 7,
};
const res = await this.makeRequest(View on GitHub (pinned to d3aa8bea5b)
Solutions
- Refresh the Shipinhao cookie by re-scanning QR login and re-saving cookieString.
- Read the appended errMsg in the thrown message (res.errMsg) — it names the server-side cause.
- Verify the proxy is stable and consistent across traceKey/upload/publish calls.
- Update the request payload/signature logic if the Shipinhao client API version changed.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check cookie presence before requesting traceKey
if (!cookieString || cookieString.length < 20) {
throw new Error('shipinhao cookie missing/expired');
} Type guard
function hasTraceKey(res: { errCode: number; data?: { traceKey?: string } }): res is { errCode: 0; data: { traceKey: string } } {
return res.errCode === 0 && typeof res.data?.traceKey === 'string';
} Try / catch
try {
const key = await service.traceKey(cookie, proxy);
} catch (e) {
const reason = e.message.replace('获取TraceKey失败,失败原因:', '');
if (reason.includes('登录') || reason.includes('cookie')) {
// trigger QR re-login to refresh cookies
}
} Prevention
- Refresh Shipinhao cookies on a schedule and before each publish
- Keep proxy stable and identical across traceKey/upload/publish calls
- Surface res.errMsg to logs for fast diagnosis
- Watch for Shipinhao API contract changes after client updates
When it happens
Trigger: Calling getPublishTraceKey / traceKey when the Shipinhao backend returns errCode != 0: expired or invalid cookieString, account risk-control restrictions, missing/changed API params, or proxy-related session mismatch.
Common situations: WeChat Channels cookies expired after re-login elsewhere, account flagged by risk control, IP changed via proxy mid-flow, or Shipinhao API version changed its response shape.
Related errors
- 获取上传参数失败,失败原因:
- ChannelAuthRefreshTokenMissing
- ChannelAuthPlatformUidMissing
- userId is required
- AiCallFailed
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/7b1b339594dbdb2b.
Report an issue: GitHub.