yikart/AiToEarn · error · AppException
ResponseCode.ChannelAccountCreateRequiredFieldMissing
ResponseCode.ChannelAccountCreateRequiredFieldMissing
Error message
ChannelAccountCreateRequiredFieldMissing
What it means
normalizeCreateInput validates generic (non-WeChat-Channels) account creation input. Both uid and nickname are required; if either is missing it throws ChannelAccountCreateRequiredFieldMissing with a data.fields array listing which fields are absent.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/accounts/account.service.ts:467
return account
}
private async emitAccountConnected(userId: string, account: Account): Promise<void> {
await this.eventStream.emit(
EventStream.Channels,
EventTopic.ChannelsAccountConnected,
{ userId, accountId: account.id, platform: account.type },
{ source: 'account-service' },
)
}
private async normalizeCreateInput(data: AccountCreateInput): Promise<NormalizedAccountCreateInput> {
if (data.type === AccountType.WeChatChannels) {
return this.normalizeWeChatChannelsCreateInput(data)
}
if (!data.uid || !data.nickname) {
throw new AppException(ResponseCode.ChannelAccountCreateRequiredFieldMissing, {
fields: [
...(!data.uid ? ['uid'] : []),
...(!data.nickname ? ['nickname'] : []),
],
})
}
const normalizedData: NormalizedAccountCreateInput = {
...data,
uid: data.uid,
nickname: data.nickname,
}
if (normalizedData.type === AccountType.RedNote && normalizedData.clientType === undefined) {
normalizedData.clientType = ClientType.WEB
}
return normalizedData
}
View on GitHub (pinned to d3aa8bea5b)
Solutions
- Include both uid and nickname in the create payload (check error data.fields for the missing one).
- Fix the plugin/fetch step that produces the profile so it returns a non-empty nickname.
- Re-authenticate the platform if uid cannot be resolved from the session.
- Send clean non-empty strings — whitespace-only or empty values count as missing.
Example fix
// before
{ type: 'twitter', uid: '123', nickname: '' }
// after
{ type: 'twitter', uid: '123', nickname: 'My Handle' } Defensive patterns
Strategy: validation
Validate before calling
const missing = []
if (!data.uid) missing.push('uid')
if (!data.nickname) missing.push('nickname')
if (missing.length) throw new Error(`Missing required fields before create: ${missing.join(', ')}`) Type guard
function hasRequiredAccountFields(d): d is AccountCreateInput & { uid: string; nickname: string } {
return typeof d.uid === 'string' && d.uid.length > 0 && typeof d.nickname === 'string' && d.nickname.length > 0
} Try / catch
try {
await createAccount(data)
} catch (e) {
if (e instanceof AppException && e.code === ResponseCode.ChannelAccountCreateRequiredFieldMissing) {
console.warn('Missing fields:', e.data.fields) // re-prompt user / re-fetch profile
} else throw e
} Prevention
- Validate uid and nickname are non-empty strings before the API call.
- Fix plugin profile-scraping to always capture a nickname.
- Read the error's data.fields array to know exactly what is missing.
- Handle empty-string and whitespace-only values as missing.
When it happens
Trigger: POSTing an account create (via createPluginAccount/createRelayAccountRecord path) with type other than WeChatChannels and either data.uid or data.nickname empty/undefined; data.fields in the error tells you which.
Common situations: Plugin scraping the social platform failed to capture the profile nickname; client omitting fields in the payload; uid passed as 0/empty string; renamed API fields not updated in the caller.
Related errors
- 无效的视频上传结果,缺少视频ID
- No subtitle entries in response
- No response from Gemini
- Invalid subtitle data: ${z.prettifyError(result.error)}
- Canvas not provided and no vid:// video source found in Trac
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/e28ba2451c22fe1b.
Report an issue: GitHub.