yikart/AiToEarn · error · AppException
ChannelAuthPlatformUidMissing
ChannelAuthPlatformUidMissing
Error message
ChannelAuthPlatformUidMissing
What it means
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.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/kwai/kwai-auth.provider.ts:87
return {
platformUid,
displayName: userInfo.displayName,
avatarUrl: userInfo.avatarUrl,
fansCount: userInfo.fanCount,
followingCount: userInfo.followCount,
raw: {
fanCount: userInfo.fanCount,
followCount: userInfo.followCount,
city: userInfo.city,
sex: userInfo.sex,
},
}
}
private getPlatformUid(input: CredentialContext): string {
if (!input.platformUid) {
throw new AppException(ResponseCode.ChannelAuthPlatformUidMissing)
}
return input.platformUid
}
}
View on GitHub (pinned to d3aa8bea5b)
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
Example fix
// before
const context = { accessToken: token.access_token }
// after
const context = { accessToken: token.access_token, platformUid: token.open_id } Defensive patterns
Strategy: validation
Validate before calling
if (!credentialContext.platformUid) {
throw new Error('Kwai openId (platformUid) missing from credential context; re-authorize the channel')
} Type guard
function hasPlatformUid(c: { platformUid?: string | null }): c is { platformUid: string } {
return typeof c.platformUid === 'string' && c.platformUid.length > 0
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ChannelAuthRefreshTokenMissing
- ChannelAuthRefreshTokenMissing
- Twitter user profile not found
- 15070
- No response from Gemini
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/eb3845765f3a136c.
Report an issue: GitHub.