{"record":{"id":"eb3845765f3a136c","repo":"yikart/AiToEarn","slug":"channelauthplatformuidmissing-eb3845","errorCode":"ChannelAuthPlatformUidMissing","errorMessage":"ChannelAuthPlatformUidMissing","messagePattern":"ChannelAuthPlatformUidMissing","errorType":"error_code","errorClass":"AppException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/kwai/kwai-auth.provider.ts","lineNumber":87,"sourceCode":"\n    return {\n      platformUid,\n      displayName: userInfo.displayName,\n      avatarUrl: userInfo.avatarUrl,\n      fansCount: userInfo.fanCount,\n      followingCount: userInfo.followCount,\n      raw: {\n        fanCount: userInfo.fanCount,\n        followCount: userInfo.followCount,\n        city: userInfo.city,\n        sex: userInfo.sex,\n      },\n    }\n  }\n\n  private getPlatformUid(input: CredentialContext): string {\n    if (!input.platformUid) {\n      throw new AppException(ResponseCode.ChannelAuthPlatformUidMissing)\n    }\n    return input.platformUid\n  }\n}\n","sourceCodeStart":69,"sourceCodeEnd":92,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/kwai/kwai-auth.provider.ts#L69-L92","documentation":"The Kwai credential context has no platformUid, so the provider cannot identify which Kwai account the credentials belong to. getPlatformUid guards this invariant when building the credential result.","triggerScenarios":"getPlatformUid (called by the platformUid getter) receives a CredentialContext whose platformUid field is undefined/empty, typically during an exchange/callback where the openId wasn't captured.","commonSituations":"OAuth callback dropped the openId from the Kwai token response; credential context assembled with partial fields; older records predating the platformUid field; exchange flow bug passing the wrong context object.","solutions":["Ensure the Kwai token/exchange response's openId is copied into the credential context","Inspect how CredentialContext is built before platformUid is read","Re-authorize the channel so a complete credential (token + openId) is stored","Add a pre-save check that platformUid exists before persisting credentials"],"exampleFix":"// before\nconst context = { accessToken: token.access_token }\n// after\nconst context = { accessToken: token.access_token, platformUid: token.open_id }","handlingStrategy":"validation","validationCode":"if (!credentialContext.platformUid) {\n  throw new Error('Kwai openId (platformUid) missing from credential context; re-authorize the channel')\n}","typeGuard":"function hasPlatformUid(c: { platformUid?: string | null }): c is { platformUid: string } {\n  return typeof c.platformUid === 'string' && c.platformUid.length > 0\n}","tryCatchPattern":null,"preventionTips":["Copy open_id from the Kwai exchange response into the credential context","Validate required context fields before calling provider.platformUid","Reject credential saves that lack platformUid","Migrate legacy records missing platformUid via re-authentication"],"tags":["kwai","oauth","missing-data","open-id"],"backgroundTag":"missing-platform-user-id","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}