{"record":{"id":"7b1b339594dbdb2b","repo":"yikart/AiToEarn","slug":"tracekey","errorCode":null,"errorMessage":"获取TraceKey失败,失败原因:","messagePattern":"获取TraceKey失败,失败原因:","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-electron/electron/plat/shipinhao/index.ts","lineNumber":596,"sourceCode":"      scene: 7,\n    };\n\n    const res = await this.makeRequest(\n      this.getPublishTraceKeyUrl,\n      {\n        method: 'POST',\n        headers: {\n          Cookie: cookieString,\n        },\n        body: requestParams,\n      },\n      proxy,\n    );\n\n    if (res.errCode === 0) {\n      return res.data.traceKey;\n    } else {\n      throw new Error('获取TraceKey失败,失败原因:' + (res.errMsg ?? '未知'));\n    }\n  }\n\n  /**\n   * 获取发布上传参数\n   * @param cookieString\n   * @param proxy\n   */\n  private async getPublishUploadParams(\n    cookieString: string,\n    proxy: string,\n  ): Promise<any> {\n    const requestParams = {\n      reqScene: 7,\n      scene: 7,\n    };\n\n    const res = await this.makeRequest(","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/electron/plat/shipinhao/index.ts#L578-L614","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// pre-check cookie presence before requesting traceKey\nif (!cookieString || cookieString.length < 20) {\n  throw new Error('shipinhao cookie missing/expired');\n}","typeGuard":"function hasTraceKey(res: { errCode: number; data?: { traceKey?: string } }): res is { errCode: 0; data: { traceKey: string } } {\n  return res.errCode === 0 && typeof res.data?.traceKey === 'string';\n}","tryCatchPattern":"try {\n  const key = await service.traceKey(cookie, proxy);\n} catch (e) {\n  const reason = e.message.replace('获取TraceKey失败,失败原因:', '');\n  if (reason.includes('登录') || reason.includes('cookie')) {\n    // trigger QR re-login to refresh cookies\n  }\n}","preventionTips":["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"],"tags":["shipinhao","api-error","auth","wechat"],"backgroundTag":"api-errcode-nonzero","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}